/* global React, INK, CREAM, PULSE, GENS, GradText, CTAButton, Reveal, useReveal, SB_EASE, CP_ACCENTS */
// Copilot feature page — Quick starts · Generative UI · Conversational editing · Publishing · Checkpoints.
const { useState: czS } = React;

const CPBadge = ({ label, ac = '#813CED', bg = CREAM }) =>
  <div style={{ display: 'inline-flex', alignItems: 'center', gap: 8, marginBottom: 18, borderRadius: 9999, padding: '7px 14px', background: bg, boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.1)' }}>
    <span style={{ width: 7, height: 7, borderRadius: '50%', background: ac }} />
    <span style={{ fontSize: 11.5, fontWeight: 700, color: INK }}>{label}</span>
  </div>;

const CPCard = ({ children, pad = 18 }) =>
  <div style={{ borderRadius: 20, background: '#fff', boxShadow: '0 24px 48px rgba(28,27,27,0.14), inset 0 0 0 1px rgba(28,27,27,0.08)', padding: pad }}>{children}</div>;

const CPSectionShell = ({ label, ac, h1, h2, sub, note, panel, flip = false, lean = 'right', bg = '#fff' }) => (
  <section style={{ background: bg, padding: '110px 56px' }}>
    <div style={{ maxWidth: 1140, margin: '0 auto', display: 'grid', gridTemplateColumns: flip ? '1.1fr 0.9fr' : '0.9fr 1.1fr', gap: 64, alignItems: 'center' }}>
      <div style={{ order: flip ? 2 : 1 }}>
        <Reveal delay={90}>
          <h2 style={{ font: '800 52px/1 var(--font-sans)', letterSpacing: '-0.03em', color: INK, margin: '0 0 18px', textWrap: 'balance' }}>{h1}<br /><GradText>{h2}</GradText></h2>
        </Reveal>
        <Reveal delay={170}><p style={{ fontSize: 17, lineHeight: 1.55, color: 'var(--text-secondary)', margin: '0 0 28px', maxWidth: 420 }}>{sub}</p></Reveal>
        <Reveal delay={250}><CTAButton>Join for free</CTAButton></Reveal>
        {note && <Reveal delay={330}><div style={{ marginTop: 26, fontSize: 13, color: 'var(--text-tertiary)' }}>{note}</div></Reveal>}
      </div>
      <Reveal delay={160} y={28} style={{ order: flip ? 1 : 2 }}>
        <div style={{ transform: lean === 'left' ? 'rotate(-1.3deg) perspective(1400px) rotateY(4deg)' : 'rotate(1.3deg) perspective(1400px) rotateY(-4deg)', transformOrigin: 'center' }}>{panel}</div>
      </Reveal>
    </div>
  </section>
);

// ---------- § 01 Quick starts ----------
const CP_STARTS = [
  ['Create a photo for social', false], ['Create a photo for OnlyFans', false], ['Create a photoshoot for social', false],
  ['Create a photoshoot for OnlyFans', false], ['Create a video for social', false], ['Find reels to clone', true]];

const QuickstartsPanel = () => {
  const [sel, setSel] = czS(-1);
  return (
    <CPCard>
      <div style={{ textAlign: 'center', padding: '10px 0 16px' }}>
        <span style={{ width: 40, height: 40, borderRadius: '50%', background: PULSE, display: 'inline-grid', placeItems: 'center', fontSize: 17, color: '#fff', marginBottom: 10 }}>✦</span>
        <div style={{ fontSize: 19, fontWeight: 800, letterSpacing: '-0.02em', color: INK }}>What should we make?</div>
        <div style={{ fontSize: 12, color: 'var(--text-secondary)', marginTop: 4 }}>Pick a starting point, or just type. Every thread binds to a Character.</div>
      </div>
      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 8, marginBottom: 14 }}>
        {CP_STARTS.map(([s, plan], i) =>
          <span key={s} onClick={() => setSel(i)} style={{ display: 'flex', alignItems: 'center', gap: 8, borderRadius: 12, padding: '11px 13px', fontSize: 11.5, fontWeight: sel === i ? 700 : 600, cursor: 'pointer', transition: 'all 0.18s',
            background: sel === i ? 'var(--brand-purple-50)' : 'rgb(250,247,247)',
            boxShadow: sel === i ? 'inset 0 0 0 1.5px var(--brand-purple-400)' : 'inset 0 0 0 1px rgba(28,27,27,0.08)', color: INK }}>
            <span style={{ flex: 1 }}>{s}</span>
            {plan && <span style={{ fontSize: 8, fontWeight: 800, letterSpacing: '0.06em', color: 'var(--brand-purple-700)', background: '#fff', border: '1px solid var(--brand-purple-200)', borderRadius: 9999, padding: '2px 7px', flexShrink: 0 }}>PLAN MODE</span>}
          </span>)}
      </div>
      <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
        <span style={{ display: 'inline-flex', alignItems: 'center', gap: 5, fontSize: 10.5, fontWeight: 700, color: 'rgba(28,27,27,0.7)', background: 'rgb(246,243,242)', boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.08)', borderRadius: 9999, padding: '6px 11px', flexShrink: 0 }}>
          <span style={{ width: 14, height: 14, borderRadius: '50%', backgroundImage: `url(${GENS[0].src})`, backgroundSize: 'cover', backgroundPosition: 'center 15%' }} />Scarlett</span>
        <div style={{ flex: 1, borderRadius: 11, background: 'rgb(235,231,231)', display: 'flex', alignItems: 'center', padding: '0 13px', height: 40, fontSize: 11.5, fontWeight: 500, color: 'rgba(28,27,27,0.5)' }}>
          {sel >= 0 ? CP_STARTS[sel][0] : 'Or just type…'}
        </div>
      </div>
    </CPCard>);
};

// ---------- § 02 Generative UI ----------
const GenUIPanel = () => {
  const [opt, setOpt] = czS(0);
  const opts = [GENS[7], GENS[1], GENS[3]];
  return (
    <CPCard>
      <div style={{ fontSize: 11, fontWeight: 700, color: 'rgba(28,27,27,0.55)', marginBottom: 10 }}>Copilot suggests · <span style={{ color: INK }}>Poolside, golden hour</span></div>
      <div style={{ display: 'grid', gridTemplateColumns: '0.95fr 1.05fr', gap: 14 }}>
        <div style={{ position: 'relative', borderRadius: 13, overflow: 'hidden', aspectRatio: '3/3.9', background: 'rgb(246,243,242)' }}>
          {opts.map((g, i) =>
            <img loading="lazy" decoding="async" key={i} src={g.src} alt="" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center 16%',
              opacity: opt === i ? 1 : 0, transition: `opacity 0.45s ${SB_EASE}` }} />)}
          <div style={{ position: 'absolute', left: 8, right: 8, bottom: 8, display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
            {[-1, 1].map((d, j) =>
              <span key={j} onClick={() => setOpt(o => (o + d + 3) % 3)} style={{ order: j ? 3 : 1, width: 26, height: 26, borderRadius: '50%', background: 'rgba(252,248,248,0.9)', display: 'grid', placeItems: 'center', cursor: 'pointer', boxShadow: '0 4px 12px rgba(28,27,27,0.25)' }}>
                <svg width="10" height="10" viewBox="0 0 16 16" fill="none" style={{ transform: d < 0 ? 'rotate(180deg)' : 'none' }}><path d="M6 3.5L10.5 8 6 12.5" stroke={INK} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" /></svg></span>)}
            <span style={{ order: 2, fontSize: 9.5, fontWeight: 700, color: '#fff', background: 'rgba(28,27,27,0.55)', backdropFilter: 'blur(6px)', borderRadius: 9999, padding: '3px 9px' }}>Option {opt + 1} / 3</span>
          </div>
        </div>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 8, justifyContent: 'center' }}>
          <div style={{ fontSize: 10, fontWeight: 700, letterSpacing: '0.08em', textTransform: 'uppercase', color: 'var(--text-tertiary)' }}>The full Create controls, inline</div>
          {[['Character', 'Scarlett'], ['Photo Control', 'Setting · Outfit · Shot'], ['Aspect', '4:5'], ['Resolution', '1K'], ['Quantity', '3 photos']].map(([k, v]) =>
            <div key={k} style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', borderRadius: 10, background: 'rgb(250,247,247)', boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.07)', padding: '8px 11px' }}>
              <span style={{ fontSize: 10.5, fontWeight: 700, color: INK }}>{k}</span>
              <span style={{ fontSize: 10.5, fontWeight: 600, color: 'rgba(28,27,27,0.55)' }}>{v}</span>
            </div>)}
          <span style={{ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', gap: 5, borderRadius: 11, height: 40, background: PULSE, color: '#fff', fontSize: 10.5, fontWeight: 800, letterSpacing: '0.05em', boxShadow: '0 8px 20px -4px rgba(104,19,212,0.45)', marginTop: 2 }}>GENERATE ✦</span>
        </div>
      </div>
    </CPCard>);
};

// ---------- § 03 Conversational editing ----------
const CP_TOOLS = ['Reimagine', 'Inpaint', 'Background', 'Expression', 'Crop', 'Filters'];
const ChatEditPanel = () => {
  const [ref, on] = useReveal(0.35);
  const [done, setDone] = czS(false);
  React.useEffect(() => {
    if (!on) return;
    const t = setInterval(() => setDone(d => !d), 3600);
    return () => clearInterval(t);
  }, [on]);
  return (
    <CPCard>
      <div ref={ref} style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>
        <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
          <span style={{ borderRadius: '16px 16px 4px 16px', background: INK, color: '#fff', padding: '9px 13px', fontSize: 12, fontWeight: 500 }}>make her top red</span>
        </div>
        <div style={{ position: 'relative', borderRadius: 13, overflow: 'hidden', height: 300, background: 'rgb(246,243,242)' }}>
          <img loading="lazy" decoding="async" src="assets/edits/base.webp" alt="" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center 12%' }} />
          <img loading="lazy" decoding="async" src="assets/edits/color.webp" alt="" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center 12%',
            opacity: done ? 1 : 0, transition: `opacity 0.7s ${SB_EASE}` }} />
          <span style={{ position: 'absolute', left: 9, bottom: 9, fontSize: 9.5, fontWeight: 700, color: '#fff', background: 'rgba(28,27,27,0.55)', backdropFilter: 'blur(6px)', borderRadius: 9999, padding: '3px 9px' }}>
            {done ? 'Edited — only the top changed' : 'Copilot targets the right image…'}</span>
        </div>
        <div style={{ display: 'flex', gap: 5, flexWrap: 'wrap' }}>
          <span style={{ fontSize: 9.5, fontWeight: 700, letterSpacing: '0.06em', textTransform: 'uppercase', color: 'var(--text-tertiary)', alignSelf: 'center', marginRight: 3 }}>Or open the suite in-thread</span>
          {CP_TOOLS.map(t =>
            <span key={t} style={{ borderRadius: 9999, padding: '5px 11px', fontSize: 10, fontWeight: 600, background: 'rgb(246,243,242)', boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.08)', color: INK }}>{t}</span>)}
        </div>
      </div>
    </CPCard>);
};

// ---------- § 04 Publishing ----------
const PublishPanel = () => (
  <CPCard>
    <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 12 }}>
      <span style={{ fontSize: 13, fontWeight: 800, color: INK }}>Create Post <span style={{ fontSize: 10, fontWeight: 700, color: 'var(--brand-purple-700)' }}>· prefilled by Copilot</span></span>
      <span style={{ fontSize: 10, fontWeight: 600, color: 'var(--text-tertiary)' }}>@scarlett.day</span>
    </div>
    <div style={{ display: 'flex', gap: 6, flexWrap: 'wrap', marginBottom: 11 }}>
      {[['Instagram', '#E1306C', true], ['Twitter/X', '#5B6470', false], ['TikTok', '#1C1B1B', false], ['Fanvue', '#1FB85A', true], ['Reddit', '#FF4500', false]].map(([n, c, on]) =>
        <span key={n} style={{ display: 'inline-flex', alignItems: 'center', gap: 5, borderRadius: 9999, padding: '5px 11px', fontSize: 10.5, fontWeight: on ? 700 : 600,
          boxShadow: on ? 'inset 0 0 0 1.5px var(--brand-purple-500)' : 'inset 0 0 0 1px rgba(28,27,27,0.1)', color: on ? INK : 'rgba(28,27,27,0.45)' }}>
          <span style={{ width: 6, height: 6, borderRadius: '50%', background: c, opacity: on ? 1 : 0.4 }} />{n}</span>)}
    </div>
    <div style={{ display: 'flex', gap: 11, marginBottom: 12 }}>
      <span style={{ width: 74, borderRadius: 11, overflow: 'hidden', flexShrink: 0, aspectRatio: '3/3.9', position: 'relative' }}>
        <img loading="lazy" decoding="async" src={GENS[7].src} alt="" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center 18%' }} />
        <span style={{ position: 'absolute', left: 4, bottom: 4, fontSize: 7.5, fontWeight: 700, color: '#fff', background: 'rgba(28,27,27,0.55)', borderRadius: 9999, padding: '2px 6px' }}>Vault</span>
      </span>
      <div style={{ flex: 1, borderRadius: 13, background: 'rgb(250,248,247)', boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.08)', padding: '11px 13px' }}>
        <div style={{ fontSize: 12, lineHeight: 1.5, color: INK }}>poolside, golden light, zero meetings. new set live now ↗</div>
        <span style={{ display: 'inline-flex', alignItems: 'center', gap: 5, marginTop: 7, fontSize: 10.5, fontWeight: 700, color: 'var(--brand-purple-700)', cursor: 'pointer' }}>✦ Rewrite in my voice</span>
      </div>
    </div>
    <div style={{ display: 'flex', alignItems: 'center', gap: 8, borderTop: '1px solid rgba(28,27,27,0.08)', paddingTop: 12 }}>
      <div>
        <div style={{ fontSize: 8.5, fontWeight: 700, letterSpacing: '0.1em', textTransform: 'uppercase', color: 'var(--text-tertiary)' }}>Publishing at</div>
        <div style={{ fontSize: 12, fontWeight: 700, color: 'var(--brand-purple-600)' }}>Tonight, 9:00 PM</div>
      </div>
      <span style={{ whiteSpace: 'nowrap', marginLeft: 'auto', borderRadius: 9999, padding: '8px 15px', fontSize: 10.5, fontWeight: 700, color: 'rgba(28,27,27,0.6)', boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.12)', cursor: 'pointer' }}>Edit first</span>
      <span style={{ whiteSpace: 'nowrap', display: 'inline-flex', alignItems: 'center', borderRadius: 9999, padding: '9px 16px', background: PULSE, color: '#fff', fontSize: 10.5, fontWeight: 700, letterSpacing: '0.05em', textTransform: 'uppercase', boxShadow: '0 8px 20px -4px rgba(104,19,212,0.4)', cursor: 'pointer' }}>Approve & schedule</span>
    </div>
  </CPCard>
);

// ---------- § 05 Checkpoints ----------
const CP_NODES = [
  { t: 'The brief', d: '“Make tonight’s post — poolside, golden hour.”', time: '8:02 PM' },
  { t: 'Generated 3 options', d: 'Same setting, three reads · you picked option 1.', time: '8:03 PM' },
  { t: 'Edit · top → red', d: 'Conversational edit, only the top changed.', time: '8:05 PM' },
  { t: 'Post scheduled', d: 'Instagram + Fanvue · tonight, 9:00 PM.', time: '8:06 PM' }];

const CheckpointsPanel = () => {
  const [at, setAt] = czS(3);
  return (
    <CPCard>
      <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', marginBottom: 14 }}>
        <span style={{ fontSize: 12.5, fontWeight: 700, color: INK }}>Thread timeline</span>
        <span style={{ fontSize: 10.5, fontWeight: 600, color: 'var(--text-tertiary)' }}>Tap a step to roll back</span>
      </div>
      <div style={{ display: 'flex', flexDirection: 'column' }}>
        {CP_NODES.map((n, i) => {
          const live = i <= at;
          return (
            <div key={n.t} onClick={() => setAt(i)} style={{ display: 'flex', gap: 12, cursor: 'pointer' }}>
              <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', width: 22, flexShrink: 0 }}>
                <span style={{ width: 20, height: 20, borderRadius: '50%', display: 'grid', placeItems: 'center', transition: 'all 0.25s', flexShrink: 0,
                  background: live ? PULSE : 'rgb(235,231,231)', boxShadow: i === at ? '0 0 0 4px var(--brand-purple-100)' : 'none' }}>
                  <svg width="9" height="9" viewBox="0 0 16 16" fill="none"><path d="M3 8.4l3.2 3.2L13.5 4" stroke={live ? '#fff' : 'rgba(28,27,27,0.4)'} strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round" /></svg></span>
                {i < CP_NODES.length - 1 && <span style={{ width: 2, flex: 1, minHeight: 26, background: i < at ? 'var(--brand-purple-300)' : 'rgb(235,231,231)', transition: 'all 0.25s' }} />}
              </div>
              <div style={{ paddingBottom: i < CP_NODES.length - 1 ? 16 : 0, opacity: live ? 1 : 0.45, transition: 'opacity 0.25s', flex: 1, minWidth: 0 }}>
                <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
                  <span style={{ fontSize: 12.5, fontWeight: 700, color: INK }}>{n.t}</span>
                  <span style={{ fontSize: 9.5, fontWeight: 600, color: 'rgba(28,27,27,0.4)' }}>{n.time}</span>
                  {i === at && <span style={{ marginLeft: 'auto', fontSize: 9, fontWeight: 700, color: 'var(--brand-purple-700)', background: 'var(--brand-purple-50)', border: '1px solid var(--brand-purple-200)', borderRadius: 9999, padding: '2px 9px', whiteSpace: 'nowrap' }}>Resume from here</span>}
                </div>
                <div style={{ fontSize: 11, lineHeight: 1.5, color: 'var(--text-secondary)', marginTop: 3 }}>{n.d}</div>
              </div>
            </div>);
        })}
      </div>
    </CPCard>);
};

const QuickstartsSection = () => <CPSectionShell label="Quick starts" ac={CP_ACCENTS['Quick starts']} h1="“What should" h2="we make?”" lean="left"
  sub="Six starting points — photo, photoshoot or video, for social or the paid platforms — or just type. Each thread binds to one Character."
  note="Find reels to clone runs in plan mode: Copilot scouts before it shoots." panel={<QuickstartsPanel />} />;
const GenUISection = () => <CPSectionShell label="Generative UI" ac={CP_ACCENTS['Generative UI']} h1="It hands you" h2="ready-to-go shots." flip lean="right" bg={CREAM}
  sub="Not just a text reply — Copilot suggests real shots with all the Create controls attached: Photo Control, aspect, resolution, quantity, your Character. Flip through the options and hit Generate."
  panel={<GenUIPanel />} />;
const ChatEditSection = () => <CPSectionShell label="Editing" ac={CP_ACCENTS.Editing} h1="Edit by" h2="saying so." lean="left"
  sub="“Make her top red” — Copilot keeps the conversation context and targets the right image. Or open the full suite inside the thread."
  panel={<ChatEditPanel />} />;
const PublishingSection = () => <CPSectionShell label="Publishing" ac={CP_ACCENTS.Publishing} h1="It writes." h2="You approve." flip lean="right" bg={CREAM}
  sub="“Create post” hands you a prefilled card — caption written in your voice, platforms picked, media from the Vault, time set. One approval ships it."
  panel={<PublishPanel />} />;
const CheckpointsSection = () => <CPSectionShell label="Checkpoints" ac={CP_ACCENTS.Checkpoints} h1="Every step," h2="a checkpoint." lean="left"
  sub="Reasoning, generations, edits, scheduled posts — each is a node on the thread. Resume from here rolls back to any earlier point."
  panel={<CheckpointsPanel />} />;

// ---------- § 06 — Everything it drives ----------
const CPP_PANEL = { borderRadius: '12px 12px 0 0', background: '#fff', boxShadow: '0 10px 24px rgba(28,27,27,0.10), inset 0 0 0 1px rgba(28,27,27,0.08)', padding: 10, height: '100%', boxSizing: 'border-box', display: 'flex', flexDirection: 'column' };
const CP_NEXT = [
  { t: 'Create Image', d: 'The composer Copilot drives — type a scene, get the set.', kind: 'image', href: '/create-image' },
  { t: 'Editing Suite', d: 'The tools it opens in-thread — inpaint to 4K upscale.', kind: 'edit', href: '/editing-suite' },
  { t: 'Post & Analyze', d: 'Where approved posts land — queued, shipped, measured.', kind: 'sched', href: '/post-analyze' }];
const CPP_ROWS = [
  { src: GENS[7].src, p: 'Instagram', time: '9:00 PM', st: 'Queued' },
  { src: GENS[1].src, p: 'Fanvue', time: '9:00 PM', st: 'Queued' },
  { src: GENS[3].src, p: 'TikTok', time: 'Yesterday', st: 'Posted' }];

const CPPipeMedia = ({ kind }) => (
  <div style={{ height: 210, background: 'rgb(246,243,242)', padding: '16px 16px 0', boxSizing: 'border-box' }}>
    {kind === 'image' &&
      <div style={CPP_PANEL}>
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 6, flex: 1, minHeight: 0, marginBottom: 8 }}>
          {['assets/create/out-mirror.webp', 'assets/create/out-garden.webp', 'assets/create/out-gym.webp'].map((src, i) =>
            <div key={src} style={{ position: 'relative', borderRadius: 7, overflow: 'hidden', boxShadow: i === 0 ? '0 0 0 2px var(--brand-purple-500)' : 'inset 0 0 0 1px rgba(28,27,27,0.08)' }}>
              <img loading="lazy" decoding="async" src={src} alt="" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center 20%' }} /></div>)}
        </div>
        <div style={{ display: 'flex', gap: 7, alignItems: 'center' }}>
          <span style={{ flex: 1, borderRadius: 8, background: 'rgb(235,231,231)', padding: '7px 10px', fontSize: 9.5, fontWeight: 500, color: 'rgba(28,27,27,0.75)', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>poolside, golden hour</span>
          <span style={{ display: 'inline-flex', alignItems: 'center', gap: 4, borderRadius: 8, padding: '7px 11px', background: PULSE, color: '#fff', fontSize: 8.5, fontWeight: 800, letterSpacing: '0.05em' }}>GENERATE <span style={{ fontSize: 8 }}>✦</span></span>
        </div>
      </div>}
    {kind === 'edit' &&
      <div style={CPP_PANEL}>
        <div style={{ position: 'relative', flex: 1, minHeight: 0, borderRadius: 8, overflow: 'hidden', background: 'rgb(246,243,242)', marginBottom: 8 }}>
          <img loading="lazy" decoding="async" src="assets/edits/color.webp" alt="" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center 10%' }} />
          <span style={{ position: 'absolute', top: 0, bottom: 0, left: '50%', width: 2, background: '#fff', boxShadow: '0 0 8px rgba(0,0,0,0.3)' }} />
          <span style={{ position: 'absolute', left: 6, bottom: 6, fontSize: 8, fontWeight: 700, letterSpacing: '0.05em', textTransform: 'uppercase', color: '#fff', background: 'rgba(20,16,23,0.6)', borderRadius: 9999, padding: '2px 7px' }}>Before</span>
          <span style={{ position: 'absolute', right: 6, bottom: 6, fontSize: 8, fontWeight: 700, letterSpacing: '0.05em', textTransform: 'uppercase', color: '#fff', background: 'rgba(20,16,23,0.6)', borderRadius: 9999, padding: '2px 7px' }}>After</span>
        </div>
        <div style={{ display: 'flex', gap: 7, alignItems: 'center' }}>
          <span style={{ flex: 1, borderRadius: 8, background: 'rgb(235,231,231)', padding: '7px 10px', fontSize: 9.5, fontWeight: 500, color: 'rgba(28,27,27,0.75)', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>make the top red</span>
          <span style={{ display: 'inline-flex', alignItems: 'center', gap: 4, borderRadius: 8, padding: '7px 11px', background: PULSE, color: '#fff', fontSize: 8.5, fontWeight: 800, letterSpacing: '0.05em' }}>APPLY <span style={{ fontSize: 8 }}>✦</span></span>
        </div>
      </div>}
    {kind === 'sched' &&
      <div style={{ ...CPP_PANEL, gap: 6 }}>
        <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 2 }}>
          <span style={{ fontSize: 10.5, fontWeight: 700, color: INK }}>Tonight</span>
          <span style={{ fontSize: 8.5, fontWeight: 700, color: 'rgba(28,27,27,0.5)' }}>Approved in-thread</span>
        </div>
        {CPP_ROWS.map((r) =>
          <div key={r.p} style={{ display: 'flex', alignItems: 'center', gap: 8, borderRadius: 9, background: 'rgb(250,247,247)', boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.07)', padding: '6px 8px', flex: 1, minHeight: 0 }}>
            <span style={{ width: 26, height: 26, borderRadius: 7, overflow: 'hidden', flexShrink: 0 }}>
              <img loading="lazy" decoding="async" src={r.src} alt="" style={{ width: '100%', height: '100%', objectFit: 'cover', objectPosition: 'center 20%' }} /></span>
            <span style={{ flex: 1, minWidth: 0 }}>
              <span style={{ display: 'block', fontSize: 9.5, fontWeight: 700, color: INK }}>{r.p}</span>
              <span style={{ display: 'block', fontSize: 8.5, color: 'rgba(28,27,27,0.5)' }}>{r.time}</span>
            </span>
            <span style={{ fontSize: 8, fontWeight: 700, borderRadius: 9999, padding: '2px 8px',
              color: r.st === 'Posted' ? '#15803D' : 'var(--brand-purple-700)',
              background: r.st === 'Posted' ? 'rgba(34,197,94,0.12)' : 'var(--brand-purple-50)',
              border: r.st === 'Posted' ? '1px solid rgba(34,197,94,0.3)' : '1px solid var(--brand-purple-200)' }}>{r.st}</span>
          </div>)}
      </div>}
  </div>
);

const CPPipelineSection = () => (
  <section style={{ background: '#fff', padding: '110px 56px' }}>
    <div style={{ maxWidth: 1140, margin: '0 auto' }}>
      <div style={{ display: 'flex', alignItems: 'flex-end', justifyContent: 'space-between', gap: 40, flexWrap: 'wrap', marginBottom: 46 }}>
        <div style={{ maxWidth: 560 }}>
          <Reveal delay={90}>
            <h2 style={{ font: '800 52px/1 var(--font-sans)', letterSpacing: '-0.03em', color: INK, margin: '0 0 16px', textWrap: 'balance' }}>
              One thread drives<br /><GradText>the whole studio.</GradText>
            </h2>
          </Reveal>
          <Reveal delay={170}>
            <p style={{ fontSize: 17, lineHeight: 1.55, color: 'var(--text-secondary)', margin: 0 }}>
              Everything Copilot does runs on the same tools you can drive yourself.
            </p>
          </Reveal>
        </div>
        <Reveal delay={240} style={{ paddingBottom: 8 }}>
          <a href="/" style={{ fontSize: 13.5, fontWeight: 600, color: 'var(--brand-purple-700)' }}>See the full tour →</a>
        </Reveal>
      </div>
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 18 }}>
        {CP_NEXT.map((c, i) =>
          <Reveal key={c.t} delay={i * 110} y={26}>
            <a href={c.href} style={{ display: 'block', borderRadius: 18, overflow: 'hidden', background: CREAM, boxShadow: 'inset 0 0 0 1px rgba(28,27,27,0.08)', color: 'inherit',
              transform: `rotate(${i === 1 ? 1 : -1}deg) perspective(1200px) rotateY(${i === 1 ? -2 : 2}deg)` }}>
              <CPPipeMedia kind={c.kind} />
              <div style={{ padding: '18px 20px 22px' }}>
                <div style={{ fontSize: 17, fontWeight: 700, letterSpacing: '-0.01em', color: INK, marginBottom: 7 }}>{c.t}</div>
                <div style={{ fontSize: 13.5, lineHeight: 1.5, color: 'var(--text-secondary)' }}>{c.d}</div>
              </div>
            </a>
          </Reveal>
        )}
      </div>
    </div>
  </section>
);

Object.assign(window, { QuickstartsSection, GenUISection, ChatEditSection, PublishingSection, CheckpointsSection, CPPipelineSection });
