// === Escena 02 — "El mismo campo, dos manos" (la paridad) ===
// Le pides que corrija el correo → el campo «Email» de la ficha cambia → EL PLANO: dos flechas
// (tu teclado y la herramienta) que se dibujan hacia el MISMO enlace, `datosPersonales.Email`
// (formulario EntidadDialog.razor:131 · herramienta set_contacto :1433) → la ventana se repinta
// al cerrar el turno → y nadie ha guardado: en el pie APARECE «Guardar», y es del humano
// (EntidadDialog.razor:523, solo con cambios sin guardar :535).
function EscenaYV02({ t }){
  // LOCUCIÓN (audio/escena-02.mp3): le pides que corrija el correo → (pausa) → el correo cambia →
  // no hay truco → el mismo campo que escribiría tu teclado → un dato, dos manos → al terminar el
  // turno la ventana se repinta → la regla en dos mitades → nadie ha guardado → aparece «Guardar» →
  // hasta que lo pulses, esto vive en memoria.
  const T = {
    pide:0.1,        // "Le pides que corrija el correo" → se teclea en el área de escribir
    cliente:1.7,     // "del cliente" → la burbuja de usuario sale disparada
    pausa:2.9,       // (pausa 0.4 s) anticipación: los tres puntos del agente
    cambia:4.0,      // "el correo cambia en el formulario" → el campo «Email» cambia de valor
    truco:6.7,       // "No hay truco" → calma; la respuesta del agente aterriza
    escribe:8.5,     // "La herramienta escribe" → la llamada set_contacto se abre y enseña su argumento
    mismo:10.3,      // "el mismo campo que escribiría tu teclado" → LAS DOS FLECHAS se dibujan
    dosmanos:13.2,   // "Un dato, dos manos" → el enlace compartido brilla y las flechas quedan fijas
    turno:15.6,      // "Cuando el agente termina su turno" → la llamada se cierra en verde
    repinta:17.6,    // "la ventana se repinta" → barrido suave sobre la mitad izquierda
    regla1:21.5,     // "si el dato está en pantalla" → la regla, mitad 1
    regla2:24.2,     // "si tú puedes cambiarlo" → la regla, mitad 2
    nadie:29.5,      // "Nadie ha guardado" → el pie entra desde abajo, con un hueco vacío
    guardar:32.1,    // "ha aparecido el botón de guardar" → «Guardar» materializa en ese hueco
    memoria:36.8,    // "esto vive en memoria" → chip gris «sin guardar» junto al botón
    salida:38.8,     // "De dónde saca el agente lo que sabe" → salida
    typeSpeed:31,    // caracteres por segundo del tecleo en el área de escribir
    arrowGap:0.35,   // desfase entre la flecha del teclado y la de la herramienta
  };

  const PETICION = 'Cambia el correo a compras@talleresmarban.es';

  // ── Geometría (misma ventana que la escena 01; el pie llega al final) ──
  const WX = 110, WY = 96, WW = 1700;
  const BARRA = 80, CUERPO = 736, PIE = 78, PANEL = 680;
  const IZQ = WW - PANEL;                       // 1020
  const pieP = clamp((t-T.nadie)/0.7,0,1), pieE = Easing.easeOutCubic(pieP);
  const WH = BARRA + CUERPO + PIE*pieE;

  // Coordenadas absolutas del campo «Email» (lo que apuntan las dos flechas)
  const EMX = 150, EMY = 452, EMW = 453, EMH = 62;

  const burbP = clamp((t-T.cliente)/0.45,0,1), burbE = Easing.easeOutBack(burbP);
  const pensando = clamp((t-T.cliente-0.35)/0.3,0,1) * (1 - clamp((t-T.cambia+0.25)/0.3,0,1));
  const toolP = clamp((t-T.cambia+0.2)/0.45,0,1), toolE = Easing.easeOutBack(toolP);
  const argP = clamp((t-T.escribe)/0.5,0,1), argE = Easing.easeOutCubic(argP);
  const okP = clamp((t-T.turno)/0.45,0,1);
  const respP = clamp((t-T.truco+0.6)/0.5,0,1), respE = Easing.easeOutCubic(respP);

  const cambiado = T.cambia <= t;
  const camPulse = t >= T.cambia && t < T.cambia+1.2 ? Math.sin((t-T.cambia)/1.2*Math.PI) : 0;

  // Las dos flechas y el enlace compartido
  const flechas = clamp((t-T.mismo)/0.45,0,1);
  const drawA = Easing.easeInOutCubic(clamp((t-T.mismo)/0.85,0,1));
  const drawB = Easing.easeInOutCubic(clamp((t-T.mismo-T.arrowGap)/0.95,0,1));
  const varP = clamp((t-T.mismo-0.2)/0.5,0,1), varE = Easing.easeOutBack(varP);
  const varGlow = t >= T.dosmanos && t < T.dosmanos+1.4 ? Math.sin((t-T.dosmanos)/1.4*Math.PI) : 0;
  const salenFlechas = clamp((t-T.nadie+0.8)/0.5,0,1);          // se retiran antes del pie
  const flechasOp = flechas*(1-salenFlechas);
  const cardDim = flechas*(1-salenFlechas);                      // la tarjeta de abajo cede el sitio

  // El barrido del repintado
  const barrido = clamp((t-T.repinta)/1.1,0,1);
  const barridoOn = 0 < barrido && barrido < 1;

  // La regla en dos mitades
  const r1 = clamp((t-T.regla1)/0.5,0,1), r1e = Easing.easeOutCubic(r1);
  const r2 = clamp((t-T.regla2)/0.5,0,1), r2e = Easing.easeOutCubic(r2);
  const reglaOut = clamp((t-T.nadie+0.9)/0.5,0,1);

  // El pie y el botón que aparece
  const guP = clamp((t-T.guardar)/0.5,0,1), guE = Easing.easeOutBack(guP);
  const guGlow = t >= T.guardar && t < T.guardar+1.5 ? Math.sin((t-T.guardar)/1.5*Math.PI) : 0;
  const foco = clamp((t-T.guardar)/0.6,0,1);                     // todo lo demás baja a 0.35
  const chipP = clamp((t-T.memoria)/0.45,0,1), chipE = Easing.easeOutBack(chipP);
  const saP = clamp((t-T.salida)/0.6,0,1), saE = Easing.easeOutCubic(saP);

  const IconBot = ({ s=26, c='#0085FF' })=>(
    <svg width={s} height={s} viewBox="0 0 24 24" fill="none" stroke={c} strokeWidth="1.8">
      <rect x="3.5" y="8" width="17" height="12" rx="3.4"/>
      <path d="M12 4.6 V8" strokeLinecap="round"/>
      <circle cx="12" cy="3.4" r="1.5" fill={c} stroke="none"/>
      <circle cx="9" cy="13.6" r="1.5" fill={c} stroke="none"/>
      <circle cx="15" cy="13.6" r="1.5" fill={c} stroke="none"/>
      <path d="M1.6 12.6 V15.6 M22.4 12.6 V15.6" strokeLinecap="round"/>
    </svg>
  );
  const IconChat = ({ s=22, c='#64748B' })=>(
    <svg width={s} height={s} viewBox="0 0 24 24" fill="none" stroke={c} strokeWidth="1.8">
      <path d="M4 4.5 H20 A2 2 0 0 1 22 6.5 V15 A2 2 0 0 1 20 17 H10.5 L5.5 21 V17 H4 A2 2 0 0 1 2 15 V6.5 A2 2 0 0 1 4 4.5 Z" strokeLinejoin="round"/>
    </svg>
  );

  const Campo = ({ label, valor, big, activo, tag })=>(
    <div style={{minWidth:0}}>
      <div style={{display:'flex', alignItems:'center', gap:12, marginBottom:9, minHeight:25}}>
        <span className="f-plex" style={{fontSize:21, fontWeight:600, color:activo && 0 < camPulse ? '#0085FF' : '#64748B'}}>{label}</span>
        {tag && 0 < varP && (
          <span className="f-mono" style={{fontSize:15, fontWeight:600, color:'#7C3AED', background:'rgba(124,58,237,0.10)',
                        border:'1px solid rgba(124,58,237,0.28)', borderRadius:99, padding:'2px 10px',
                        opacity:clamp(varP*1.3,0,1), transform:`scale(${lerp(0.7,1,varE)})`,
                        boxShadow:0 < varGlow ? `0 0 ${varGlow*24}px rgba(124,58,237,0.7)` : 'none'}}>{tag}</span>
        )}
      </div>
      <div style={{height:EMH, borderRadius:10, background:'#fff', display:'flex', alignItems:'center', padding:'0 18px',
                   border:`1px solid ${activo && 0 < camPulse ? '#0085FF' : '#D9E1EC'}`,
                   boxShadow:activo && 0 < camPulse ? `0 0 ${camPulse*26}px rgba(0,133,255,0.40)` : 'none'}}>
        <span className="f-plex" style={{fontSize:big ? 30 : 26, color:'#0F172A', whiteSpace:'nowrap',
                                         overflow:'hidden', textOverflow:'ellipsis'}}>{valor}</span>
      </div>
    </div>
  );

  const Selector = ({ label, valor })=>(
    <div style={{minWidth:0}}>
      <div className="f-plex" style={{fontSize:18, fontWeight:600, color:'#94A3B8', marginBottom:8}}>{label}</div>
      <div style={{height:54, borderRadius:9, border:'1px solid #D9E1EC', background:'#fff', display:'flex',
                   alignItems:'center', justifyContent:'space-between', padding:'0 14px', gap:8}}>
        <span className="f-plex" style={{fontSize:22, color:'#334155', whiteSpace:'nowrap', overflow:'hidden', textOverflow:'ellipsis'}}>{valor}</span>
        <span style={{color:'#94A3B8', fontSize:14}}>▾</span>
      </div>
    </div>
  );

  const Pildora = ({ label, activa })=>(
    <span className="f-plex" style={{display:'inline-flex', alignItems:'center', padding:'6px 14px', borderRadius:99,
                  fontSize:17, fontWeight:activa ? 700 : 500,
                  background:activa ? 'rgba(0,133,255,0.12)' : '#F1F5F9',
                  border:`1px solid ${activa ? 'rgba(0,133,255,0.35)' : '#E2E8F0'}`,
                  color:activa ? '#0085FF' : '#94A3B8'}}>{label}</span>
  );

  return (
    <SlideCanvas variant="light">
      <div className="f-plex" style={{position:'absolute', top:44, left:0, right:0, textAlign:'center',
                                      fontSize:19, fontWeight:700, letterSpacing:'3.4px', color:'#94A3B8'}}>
        PARIDAD · EL MISMO CAMPO, DOS MANOS
      </div>

      {/* ═══════════ LA VENTANA ═══════════ */}
      <div style={{position:'absolute', left:WX, top:WY, width:WW, height:WH,
                   background:'#fff', borderRadius:18, border:'1px solid #E2E8F0',
                   boxShadow:'0 34px 84px rgba(15,23,42,0.14)', overflow:'hidden'}}>

        {/* Barra de título — «Editar Entidad» + smart_toy + «Yudo» + interruptor encendido. Sin X. */}
        <div style={{height:BARRA, display:'flex', alignItems:'center', padding:'0 30px',
                     borderBottom:'1px solid #E8EDF3', background:'#FBFCFE',
                     opacity:lerp(1, 0.42, foco)}}>
          <span className="f-plex" style={{fontSize:29, fontWeight:700, color:'#0F172A', letterSpacing:'-0.02em'}}>Editar Entidad</span>
          <div style={{flex:1}}/>
          <div style={{display:'flex', alignItems:'center', gap:14}}>
            <IconBot s={26}/>
            <span className="f-plex" style={{fontSize:23, fontWeight:700, color:'#0F172A'}}>Yudo</span>
            <div style={{position:'relative', width:56, height:30, borderRadius:99, background:'#0085FF'}}>
              <div style={{position:'absolute', top:3, left:29, width:24, height:24, borderRadius:99,
                           background:'#fff', boxShadow:'0 2px 6px rgba(15,23,42,0.30)'}}/>
            </div>
          </div>
        </div>

        {/* Cuerpo */}
        <div style={{display:'flex', height:CUERPO, position:'relative'}}>

          {/* ── La ficha ── */}
          <div style={{width:IZQ, flexShrink:0, padding:'32px 40px', position:'relative', opacity:lerp(1, 0.35, foco)}}>
            <div style={{display:'flex', alignItems:'center', gap:26, height:62}}>
              <div style={{display:'flex', border:'1px solid #D9E1EC', borderRadius:10, overflow:'hidden'}}>
                <span className="f-plex" style={{padding:'13px 26px', fontSize:22, color:'#94A3B8', background:'#F8FAFC'}}>Personal</span>
                <span className="f-plex" style={{padding:'13px 26px', fontSize:22, fontWeight:700, color:'#fff', background:'#0085FF'}}>Empresa</span>
              </div>
              <div style={{flex:1}}/>
              <div style={{display:'flex', alignItems:'center', gap:10}}>
                <div style={{width:46, height:26, borderRadius:99, background:'#10B981', position:'relative'}}>
                  <div style={{position:'absolute', top:3, left:23, width:20, height:20, borderRadius:99, background:'#fff'}}/>
                </div>
                <span className="f-plex" style={{fontSize:20, color:'#334155'}}>Es Cliente</span>
              </div>
              <div style={{display:'flex', alignItems:'center', gap:10}}>
                <div style={{width:46, height:26, borderRadius:99, background:'#CBD5E1', position:'relative'}}>
                  <div style={{position:'absolute', top:3, left:3, width:20, height:20, borderRadius:99, background:'#fff'}}/>
                </div>
                <span className="f-plex" style={{fontSize:20, color:'#94A3B8'}}>Título automático</span>
              </div>
            </div>

            <div style={{display:'grid', gridTemplateColumns:'1fr 1fr', gap:'26px 34px', marginTop:26}}>
              <Campo label="Razón social" valor="Talleres Marbán, S.L."/>
              <Campo label="ID Fiscal" valor="B98314207"/>
              <Campo label="Email" big activo tag="datosPersonales.Email"
                     valor={cambiado ? 'compras@talleresmarban.es' : 'info@talleresmarban.es'}/>
              <Campo label="Teléfono" valor="961 244 180"/>
            </div>

            <div style={{marginTop:26, padding:22, borderRadius:14, border:'1px solid #E8EDF3', background:'#F8FAFC',
                         opacity:lerp(1, 0.16, cardDim)}}>
              <div className="f-plex" style={{fontSize:19, fontWeight:700, letterSpacing:'1.6px', color:'#64748B', marginBottom:18}}>
                CONFIGURACIÓN CLIENTE
              </div>
              <div style={{display:'grid', gridTemplateColumns:'1fr 1fr', gap:'18px 22px'}}>
                <Selector label="Tipo Venta" valor="Factura"/>
                <Selector label="Impuesto" valor="IVA 21 %"/>
                <Selector label="Tipo de Cliente" valor="Nacional"/>
                <Selector label="Cuenta contable (430)" valor="43000012"/>
              </div>
            </div>

            {/* El repintado del diálogo al cerrar el turno */}
            {barridoOn && <ScanLine y={0} height={CUERPO} progress={barrido} width={IZQ}/>}
          </div>

          {/* ── El panel de Yudo ── */}
          <div style={{width:PANEL, flexShrink:0, borderLeft:'1px solid #E2E8F0', background:'#FCFDFF',
                       display:'flex', flexDirection:'column', opacity:lerp(1, 0.35, foco)}}>

            {/* CABECERA 1 */}
            <div style={{height:64, flexShrink:0, display:'flex', alignItems:'center', gap:12, padding:'0 18px',
                         borderBottom:'1px solid #E8EDF3', background:'#fff'}}>
              <IconBot s={24}/>
              <span className="f-plex" style={{fontSize:25, fontWeight:700, color:'#0F172A'}}>Yudo - Entidad</span>
              <span className="f-mono" style={{fontSize:16, fontWeight:700, color:'#0085FF', padding:'2px 9px',
                            borderRadius:99, background:'rgba(0,133,255,0.12)', border:'1px solid rgba(0,133,255,0.30)'}}>IA</span>
              <div style={{flex:1}}/>
              <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="#94A3B8" strokeWidth="2.1">
                <path d="M5 5 L19 19 M19 5 L5 19" strokeLinecap="round"/>
              </svg>
            </div>

            {/* CABECERA 2 — con «Limpiar chat», porque ya hay mensajes */}
            <div style={{flexShrink:0, padding:'12px 18px 14px', borderBottom:'1px solid #E8EDF3', background:'#fff'}}>
              <div style={{display:'flex', alignItems:'center', gap:10}}>
                <IconChat s={22}/>
                <span className="f-plex" style={{fontSize:22, fontWeight:600, color:'#334155'}}>Yudo - Entidad</span>
                <div style={{flex:1}}/>
                <span className="f-plex" style={{fontSize:16, color:'#64748B'}}>Historial</span>
                <span className="f-plex" style={{fontSize:16, color:'#64748B'}}>Información de sesión</span>
                {0 < burbP && <span className="f-plex" style={{fontSize:16, color:'#64748B', opacity:burbP}}>Limpiar chat</span>}
              </div>
              <div style={{display:'flex', gap:9, marginTop:12}}>
                <Pildora label="Rápido"/><Pildora label="Equilibrado" activa/><Pildora label="Razonador"/>
              </div>
            </div>

            {/* CUERPO del chat */}
            <div style={{flex:1, minHeight:0, padding:'16px 18px', display:'flex', flexDirection:'column', gap:16}}>
              {/* Burbuja de usuario */}
              {0 < burbP && (
                <div style={{alignSelf:'flex-end', maxWidth:520, padding:'14px 18px', borderRadius:'14px 14px 4px 14px',
                             background:'#0085FF', opacity:clamp(burbP*1.3,0,1),
                             transform:`translateY(${(1-burbE)*14}px) scale(${lerp(0.94,1,burbE)})`}}>
                  <span className="f-plex" style={{fontSize:21, color:'#fff', lineHeight:1.35}}>{PETICION}</span>
                </div>
              )}
              {/* Anticipación */}
              {0.02 < pensando && (
                <div style={{alignSelf:'flex-start', display:'flex', gap:7, padding:'14px 18px', borderRadius:14,
                             background:'#F1F5F9', opacity:pensando}}>
                  {[0,1,2].map(i=>(
                    <span key={i} style={{width:9, height:9, borderRadius:99, background:'#94A3B8',
                                          opacity:0.35 + 0.65*Math.abs(Math.sin((t*3.2)-i*0.6))}}/>
                  ))}
                </div>
              )}
              {/* La llamada a la herramienta */}
              {0 < toolP && (
                <div style={{alignSelf:'flex-start', width:'100%', borderRadius:12, border:'1px solid #E2E8F0',
                             background:'#fff', overflow:'hidden', opacity:clamp(toolP*1.3,0,1),
                             transform:`scale(${lerp(0.92,1,toolE)})`, transformOrigin:'left center'}}>
                  <div style={{display:'flex', alignItems:'center', gap:10, padding:'12px 14px', background:'#F8FAFC'}}>
                    <svg width="19" height="19" viewBox="0 0 24 24" fill="none" stroke={0.02 < okP ? '#059669' : '#0085FF'} strokeWidth="2.2">
                      {0.02 < okP
                        ? <><circle cx="12" cy="12" r="9.5"/><path d="M7.5 12.5 L10.8 15.8 L16.5 9.5" strokeLinecap="round"/></>
                        : <path d="M14.5 3.5 A5.5 5.5 0 0 0 9 12.5 L3.5 18 V20.5 H6 L11.5 15 A5.5 5.5 0 0 0 20.5 9.5 L17 13 L13 12 L12 8 Z" strokeLinejoin="round"/>}
                    </svg>
                    <span className="f-mono" style={{fontSize:18, fontWeight:700, color:'#0F172A'}}>set_contacto</span>
                    <div style={{flex:1}}/>
                    {0.02 < okP && <span className="f-plex" style={{fontSize:15, fontWeight:700, color:'#059669', opacity:okP}}>hecho</span>}
                  </div>
                  {0 < argP && (
                    <div style={{padding:'12px 14px', borderTop:'1px solid #EEF2F6', opacity:clamp(argP*1.3,0,1),
                                 transform:`translateY(${(1-argE)*-6}px)`}}>
                      <span className="f-mono" style={{fontSize:17, color:'#334155', lineHeight:1.5}}>
                        email <span style={{color:'#94A3B8'}}>=</span> <span style={{color:'#c2185b'}}>"compras@talleresmarban.es"</span>
                      </span>
                      <div className="f-mono" style={{fontSize:15, color:'#94A3B8', marginTop:6}}>
                        escribe datosPersonales.Email
                      </div>
                    </div>
                  )}
                </div>
              )}
              {/* Respuesta del agente */}
              {0 < respP && (
                <div style={{alignSelf:'flex-start', maxWidth:520, padding:'14px 18px', borderRadius:'14px 14px 14px 4px',
                             background:'#F1F5F9', border:'1px solid #E2E8F0', opacity:clamp(respP*1.3,0,1),
                             transform:`translateY(${(1-respE)*12}px)`}}>
                  <span className="f-plex" style={{fontSize:21, color:'#334155', lineHeight:1.4}}>
                    Hecho. El correo queda en la ficha. Revísalo y guarda tú cuando quieras.
                  </span>
                </div>
              )}
            </div>

            {/* ÁREA DE ESCRIBIR */}
            <div style={{flexShrink:0, padding:'0 18px 18px'}}>
              <div style={{display:'flex', alignItems:'center', gap:12, height:62, padding:'0 14px',
                           borderRadius:12, border:`1px solid ${t < T.cliente ? '#0085FF' : '#D9E1EC'}`, background:'#fff'}}>
                <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="#94A3B8" strokeWidth="1.9">
                  <path d="M20 11 L11.5 19.5 A4.5 4.5 0 0 1 5 13 L13.5 4.5 A3.2 3.2 0 0 1 18 9 L9.8 17.2 A1.8 1.8 0 0 1 7.3 14.7 L15 7" strokeLinecap="round" strokeLinejoin="round"/>
                </svg>
                <span style={{flex:1, minWidth:0, overflow:'hidden', whiteSpace:'nowrap'}}>
                  {t < T.cliente
                    ? <Typewriter text={PETICION} start={T.pide} cps={T.typeSpeed} t={t} caret
                                  style={{fontFamily:"'IBM Plex Sans',sans-serif", fontSize:20, color:'#0F172A'}}/>
                    : <span className="f-plex" style={{fontSize:20, color:'#94A3B8'}}>Escribe aqui...</span>}
                </span>
                <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="#94A3B8" strokeWidth="1.9">
                  <rect x="9" y="2.5" width="6" height="11" rx="3"/>
                  <path d="M5.5 11.5 A6.5 6.5 0 0 0 18.5 11.5 M12 18 V21.5" strokeLinecap="round"/>
                </svg>
                <span style={{width:40, height:40, borderRadius:10, background:'#0085FF', display:'flex',
                              alignItems:'center', justifyContent:'center'}}>
                  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#fff" strokeWidth="2.2">
                    <path d="M3.5 12 L20.5 12 M13.5 5 L20.5 12 L13.5 19" strokeLinecap="round" strokeLinejoin="round"/>
                  </svg>
                </span>
              </div>
            </div>
          </div>
        </div>

        {/* ── El pie: entra desde abajo, con un hueco vacío entre «Ver ficha completa» y «Cerrar» ── */}
        {0 < pieP && (
          <div style={{height:PIE, display:'flex', alignItems:'center', padding:'0 30px', gap:16,
                       borderTop:'1px solid #E8EDF3', background:'#FBFCFE',
                       transform:`translateY(${(1-pieE)*PIE}px)`}}>
            <span className="f-plex" style={{fontSize:21, fontWeight:600, color:'#0085FF', opacity:lerp(1,0.42,foco)}}>Ver ficha completa</span>
            <div style={{flex:1}}/>
            {0 < chipP && (
              <span className="f-plex" style={{fontSize:17, fontWeight:600, color:'#64748B', padding:'8px 16px',
                            borderRadius:99, background:'#F1F5F9', border:'1px dashed #CBD5E1',
                            opacity:clamp(chipP*1.3,0,1), transform:`scale(${lerp(0.85,1,chipE)})`}}>sin guardar</span>
            )}
            {/* El hueco: aquí materializa «Guardar» */}
            <span style={{display:'inline-flex', alignItems:'center', justifyContent:'center', minWidth:168, height:52,
                          borderRadius:9, background:0 < guP ? '#0085FF' : 'transparent',
                          boxShadow:0 < guGlow ? `0 10px 26px rgba(0,133,255,0.36), 0 0 ${guGlow*40}px rgba(0,133,255,0.55)` : 'none',
                          transform:`scale(${0 < guP ? lerp(0.7,1,guE) : 1})`, opacity:clamp(guP*1.4,0,1)}}>
              <span className="f-plex" style={{fontSize:22, fontWeight:700, color:'#fff'}}>Guardar</span>
            </span>
            <span className="f-plex" style={{fontSize:21, fontWeight:600, color:'#64748B', padding:'12px 26px',
                          borderRadius:9, border:'1px solid #D9E1EC', background:'#fff', opacity:lerp(1,0.42,foco)}}>Cerrar</span>
          </div>
        )}
      </div>

      {/* ═══════════ EL PLANO: dos manos, un solo enlace ═══════════ */}
      {0.01 < flechasOp && (
        <>
          <svg style={{position:'absolute', inset:0, pointerEvents:'none', opacity:flechasOp}} width="1920" height="1080" viewBox="0 0 1920 1080">
            {/* Mano 1 — el teclado, desde abajo */}
            <path d="M330 646 L330 530" pathLength="100" stroke="#0085FF" strokeWidth="4" fill="none" strokeLinecap="round"
                  strokeDasharray="100" strokeDashoffset={100*(1-drawA)}/>
            <path d="M321 540 L330 528 L339 540" stroke="#0085FF" strokeWidth="4" fill="none" strokeLinecap="round"
                  strokeLinejoin="round" opacity={clamp((drawA-0.82)/0.18,0,1)}/>
            {/* Mano 2 — la herramienta, desde el panel, cruzando el reparto */}
            <path d="M1145 462 Q 880 552 620 496" pathLength="100" stroke="#7C3AED" strokeWidth="4" fill="none" strokeLinecap="round"
                  strokeDasharray="100" strokeDashoffset={100*(1-drawB)}/>
            <path d="M634 486 L616 496 L631 506" stroke="#7C3AED" strokeWidth="4" fill="none" strokeLinecap="round"
                  strokeLinejoin="round" opacity={clamp((drawB-0.82)/0.18,0,1)}/>
          </svg>
          {/* El extremo humano */}
          <div style={{position:'absolute', left:170, top:648, opacity:flechasOp*clamp(drawA*1.4,0,1)}}>
            <span className="f-plex" style={{display:'inline-flex', alignItems:'center', gap:12, padding:'14px 22px',
                          borderRadius:12, background:'#fff', border:'2px solid #0085FF',
                          boxShadow:'0 12px 30px rgba(0,133,255,0.20)', fontSize:24, fontWeight:700, color:'#0085FF'}}>
              <svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="#0085FF" strokeWidth="1.9">
                <rect x="2" y="6" width="20" height="12" rx="2.5"/>
                <path d="M6 10 H6.01 M10 10 H10.01 M14 10 H14.01 M18 10 H18.01 M8 14 H16" strokeLinecap="round"/>
              </svg>
              Tu teclado
            </span>
          </div>
        </>
      )}

      {/* ═══════════ La regla, en dos mitades ═══════════ */}
      {0 < r1 && reglaOut < 1 && (
        <div style={{position:'absolute', left:0, right:0, top:938, display:'flex', flexDirection:'column',
                     alignItems:'center', gap:14, opacity:1-reglaOut}}>
          <div style={{display:'flex', alignItems:'center', gap:14, opacity:r1, transform:`translateY(${(1-r1e)*12}px)`}}>
            <svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="#0085FF" strokeWidth="2">
              <path d="M1.8 12 S5.5 5 12 5 S22.2 12 22.2 12 S18.5 19 12 19 S1.8 12 1.8 12 Z" strokeLinejoin="round"/>
              <circle cx="12" cy="12" r="3.2"/>
            </svg>
            <span className="f-plex" style={{fontSize:34, fontWeight:700, color:'#0F172A'}}>
              Lo que ves, <span style={{color:'#0085FF'}}>lo lee</span>
            </span>
          </div>
          <div style={{display:'flex', alignItems:'center', gap:14, opacity:r2, transform:`translateY(${(1-r2e)*12}px)`}}>
            <svg width="30" height="30" viewBox="0 0 24 24" fill="none" stroke="#059669" strokeWidth="2">
              <path d="M4 20 L4 16.2 L16 4.2 A2.6 2.6 0 0 1 19.8 8 L7.8 20 Z" strokeLinejoin="round"/>
            </svg>
            <span className="f-plex" style={{fontSize:34, fontWeight:700, color:'#0F172A'}}>
              Lo que cambias, <span style={{color:'#059669'}}>lo cambia</span>
            </span>
          </div>
        </div>
      )}

      {/* Salida */}
      {0 < saP && (
        <div className="f-plex" style={{position:'absolute', left:0, right:0, top:1014, textAlign:'center', fontSize:32,
                                        fontWeight:500, color:'#64748B', opacity:saE, transform:`translateY(${(1-saE)*12}px)`}}>
          De dónde saca el agente lo que sabe de la ventana.
        </div>
      )}
    </SlideCanvas>
  );
}
Object.assign(window, { EscenaYV02 });
