// urlapi.me Landing Page — sections (split for size)

const { useState: lpUseState, useEffect: lpUseEffect, useRef: lpUseRef } = React;

function GlitchLogo() {
  return (
    <div style={{ position: "relative", textAlign: "center" }}>
      <div style={{ position: "absolute", inset: 0, color: "#FF5C7A", mixBlendMode: "screen", animation: "glitch1 4s infinite", opacity: 0.7 }}>
        <div className="display glitch-logo" style={{ fontSize: "clamp(56px, 10vw, 140px)", fontWeight: 800, letterSpacing: -0.05 }}>
          urlapi<span style={{ color: "#FF5C7A" }}>.</span>me
        </div>
      </div>
      <div style={{ position: "absolute", inset: 0, color: "#5CC8FF", mixBlendMode: "screen", animation: "glitch2 4s infinite", opacity: 0.7 }}>
        <div className="display glitch-logo" style={{ fontSize: "clamp(56px, 10vw, 140px)", fontWeight: 800, letterSpacing: -0.05 }}>
          urlapi<span style={{ color: "#5CC8FF" }}>.</span>me
        </div>
      </div>
      <div style={{ position: "relative" }}>
        <div className="display glitch-logo" style={{
          fontSize: "clamp(56px, 10vw, 140px)", fontWeight: 800, letterSpacing: -0.05,
          background: "linear-gradient(180deg, #FFFFFF 0%, #888899 100%)",
          WebkitBackgroundClip: "text", WebkitTextFillColor: "transparent",
          textShadow: "0 0 80px var(--accent-glow)",
        }}>
          urlapi<span style={{
            background: "linear-gradient(135deg, var(--accent), var(--accent-2))",
            WebkitBackgroundClip: "text", WebkitTextFillColor: "transparent",
          }}>.</span>me
        </div>
      </div>
    </div>
  );
}

// ─── NAV ────────────────────────────────────────────────────────
function Nav() {
  return (
    <nav style={{
      position: "sticky", top: 0, zIndex: 50,
      background: "rgba(6,6,10,0.78)", backdropFilter: "blur(14px)",
      WebkitBackdropFilter: "blur(14px)",
      borderBottom: "1px solid var(--border)",
    }}>
      <div className="wrap nav-row" style={{ height: 60, display: "flex", alignItems: "center", justifyContent: "space-between" }}>
        <div style={{ display: "flex", alignItems: "center", gap: 28 }}>
          <a href="/" style={{ display: "flex", alignItems: "center", gap: 8 }}>
            <img src="/assets/icon.svg" alt="" width="28" height="28" style={{ display: "block" }} />
            <span className="display" style={{ fontSize: 17, fontWeight: 700 }}>urlapi<span style={{ color: "var(--accent)" }}>.</span>me</span>
            <span className="mono" style={{ fontSize: 9, padding: "2px 5px", background: "var(--accent-soft)", color: "var(--accent)", borderRadius: 3, letterSpacing: 0.06 }}>BETA</span>
          </a>
          <div className="nav-links" style={{ display: "flex", gap: 22, fontSize: 13, color: "var(--text-mid)" }}>
            {[
              ["機能", "#features"],
              ["API/MCP", "#developer"],
              ["料金", "#pricing"],
              ["TQO", "/tqo"],
              ["Docs", "/docs/"],
              ["Status", "/status"],
            ].map(([l, h]) => (
              <a key={l} href={h} style={{ cursor: "pointer" }} onMouseEnter={e => e.target.style.color = "var(--text)"} onMouseLeave={e => e.target.style.color = ""}>{l}</a>
            ))}
          </div>
        </div>
        <div style={{ display: "flex", alignItems: "center", gap: 10 }}>
          <div style={{ display: "flex", background: "var(--bg-2)", border: "1px solid var(--border)", borderRadius: 6, padding: 2 }}>
            <a href="/" className="mono" style={{ padding: "4px 9px", fontSize: 10.5, color: "var(--accent)", background: "var(--accent-soft)", borderRadius: 4, textDecoration: "none", letterSpacing: 0.08 }}>JP</a>
            <a href="/en/" className="mono" style={{ padding: "4px 9px", fontSize: 10.5, color: "var(--text-mute)", textDecoration: "none", letterSpacing: 0.08 }}>EN</a>
          </div>
          <a href="/app/login" style={{
            padding: "8px 12px", fontSize: 12.5, color: "var(--text-mid)",
            textDecoration: "none", cursor: "pointer",
          }} onMouseEnter={e => e.target.style.color = "var(--text)"} onMouseLeave={e => e.target.style.color = ""}>ログイン</a>
          <a className="nav-cta" href="/app/signup" style={{
            padding: "8px 14px",
            background: "linear-gradient(135deg, var(--accent), var(--accent-2))",
            color: "white",
            border: "none", borderRadius: 7, fontSize: 12.5, fontWeight: 600, cursor: "pointer",
            display: "inline-flex", alignItems: "center", gap: 6,
            textDecoration: "none",
            boxShadow: "0 0 20px var(--accent-glow)",
          }}>無料で始める <I.Right size={11} /></a>
        </div>
      </div>
    </nav>
  );
}

// ─── HERO ───────────────────────────────────────────────────────
function Hero() {
  return (
    <section className="hero-section" style={{ position: "relative", overflow: "hidden", padding: "16px 24px 0" }}>
      {/* Aurora background */}
      <div style={{
        position: "absolute", inset: 0, pointerEvents: "none",
        background: "radial-gradient(ellipse 800px 500px at 50% -10%, var(--accent-glow), transparent 60%), radial-gradient(ellipse 600px 400px at 20% 30%, #5CC8FF22, transparent 60%)",
      }} />
      <div style={{
        position: "absolute", inset: 0, pointerEvents: "none",
        backgroundImage: "linear-gradient(to right, #FFFFFF06 1px, transparent 1px), linear-gradient(to bottom, #FFFFFF06 1px, transparent 1px)",
        backgroundSize: "64px 64px",
        maskImage: "radial-gradient(ellipse at 50% 30%, black 30%, transparent 70%)",
      }} />

      <div className="center-stack" style={{ position: "relative", zIndex: 2, display: "flex", flexDirection: "column", maxWidth: 1280, marginInline: "auto", width: "100%" }}>

        {/* COMING pill */}
        <div style={{ display: "flex", justifyContent: "center", marginBottom: 30 }}>
          <span className="mono" style={{
            display: "inline-flex", alignItems: "center", gap: 8,
            padding: "6px 14px",
            background: "rgba(124,92,255,0.08)",
            border: "1px solid var(--accent-soft)",
            borderRadius: 999, fontSize: 11, color: "var(--accent-2)", letterSpacing: 0.14,
            backdropFilter: "blur(10px)",
          }}>
            <span style={{ width: 8, height: 8, borderRadius: 4, background: "var(--accent)", boxShadow: "0 0 12px var(--accent)", animation: "pulse-soft 1.5s infinite" }} />
            NOW LIVE · 無料で公開中
          </span>
        </div>

        {/* GlitchLogo */}
        <GlitchLogo />

        {/* Tagline */}
        <div style={{ textAlign: "center", marginTop: 30, animation: "float-up .8s .2s both" }}>
          <h2 className="display tagline" style={{
            fontSize: "clamp(38px, 6.4vw, 76px)", fontWeight: 800, margin: 0,
            color: "var(--text)", letterSpacing: -0.04, lineHeight: 1.05,
          }}>
            クリックを<br />
            <span style={{
              background: "linear-gradient(135deg, var(--accent-2), #5CC8FF)",
              WebkitBackgroundClip: "text", WebkitTextFillColor: "transparent",
            }}>"データ資産"</span>に変えるAI
          </h2>
          <p className="mono" style={{ fontSize: 14, color: "var(--text-mute)", marginTop: 24, letterSpacing: 0.04, lineHeight: 1.65 }}>
            トラフィックの価値を最大化<br />
            Powered by <a href="https://9lick.me" target="_blank" rel="noopener noreferrer" style={{ color: "var(--accent-2)", textDecoration: "none", borderBottom: "1px solid var(--accent-soft)" }}>9lick.me</a>
          </p>
          <div style={{ marginTop: 18 }}>
            <a href="/tqo" style={{
              display: "inline-flex", alignItems: "center", gap: 8,
              padding: "10px 18px",
              fontSize: 13, color: "var(--accent-2)",
              letterSpacing: 0.04,
              border: "1px solid var(--accent-soft)", borderRadius: 8,
              background: "rgba(124,92,255,0.06)",
              textDecoration: "none",
              transition: "all .15s",
            }}
            onMouseEnter={e => { e.currentTarget.style.background = "rgba(124,92,255,0.16)"; e.currentTarget.style.color = "var(--accent)"; }}
            onMouseLeave={e => { e.currentTarget.style.background = "rgba(124,92,255,0.06)"; e.currentTarget.style.color = "var(--accent-2)"; }}>
              TQO 白書を読む →
            </a>
          </div>
        </div>

        {/* Signup CTA */}
        <div id="signup" style={{ display: "flex", flexDirection: "column", alignItems: "center", marginTop: 24, gap: 14 }}>
          <div style={{
            width: "100%", maxWidth: 720,
            background: "rgba(10,10,18,0.65)",
            border: "1px solid var(--border-strong)",
            borderRadius: 14, padding: "18px 22px",
            backdropFilter: "blur(20px)", WebkitBackdropFilter: "blur(20px)",
            boxShadow: "0 0 40px rgba(124,92,255,0.15)",
          }}>
            <div className="mono" style={{ fontSize: 11, color: "var(--accent-2)", letterSpacing: 0.18, marginBottom: 14, display: "flex", alignItems: "center", gap: 8, textTransform: "uppercase" }}>
              <span style={{ width: 6, height: 6, borderRadius: 3, background: "var(--accent)", boxShadow: "0 0 8px var(--accent)" }} />
              無料ではじめる
            </div>
            <div className="display" style={{ fontSize: 18, fontWeight: 700, color: "var(--text)", marginBottom: 6, lineHeight: 1.4, letterSpacing: -0.01 }}>
              あなたの AI を urlapi に紹介するところから。
            </div>
            <div style={{ fontSize: 13, color: "var(--text-mute)", marginBottom: 16, lineHeight: 1.55 }}>
              クレカ登録なし、いますぐ無料ではじめられます。
            </div>
            <form onSubmit={async (e) => {
              e.preventDefault();
              const email = e.target.elements['your-email'].value.trim();
              if (!email) return;
              const btn = e.target.querySelector('button[type="submit"]');
              const original = btn.innerHTML;
              btn.disabled = true;
              btn.style.opacity = 0.6;
              btn.innerHTML = '送信中...';
              window.location.href = '/app/signup?email=' + encodeURIComponent(email);
            }} style={{ display: "flex", flexDirection: "column", gap: 10 }}>
              <div className="signup-input-row" style={{ display: "flex", gap: 10 }}>
                <input
                  type="email" name="your-email" required
                  placeholder="your@email.com"
                  className="mono"
                  style={{
                    flex: 1, minWidth: 0,
                    padding: "16px 18px",
                    background: "var(--bg-2)",
                    border: "1px solid var(--border-strong)",
                    borderRadius: 10, color: "var(--text)", fontSize: 15,
                    outline: "none", fontFamily: "var(--font-mono)",
                  }}
                  onFocus={e => { e.target.style.borderColor = "var(--accent)"; e.target.style.boxShadow = "0 0 0 3px var(--accent-soft)"; }}
                  onBlur={e => { e.target.style.borderColor = "var(--border-strong)"; e.target.style.boxShadow = "none"; }}
                />
                <button type="submit" style={{
                  padding: "16px 32px",
                  background: "linear-gradient(135deg, var(--accent), var(--accent-2))",
                  border: "none", borderRadius: 10,
                  fontSize: 15, fontWeight: 700, color: "white",
                  display: "inline-flex", alignItems: "center", gap: 8,
                  boxShadow: "0 0 32px var(--accent-glow), 0 6px 18px rgba(124,92,255,0.4)",
                  whiteSpace: "nowrap", cursor: "pointer",
                  letterSpacing: 0.04,
                  transition: "transform .15s, box-shadow .15s",
                }}
                onMouseEnter={e => { e.currentTarget.style.transform = "translateY(-1px)"; e.currentTarget.style.boxShadow = "0 0 40px var(--accent-glow), 0 10px 24px rgba(124,92,255,0.5)"; }}
                onMouseLeave={e => { e.currentTarget.style.transform = "translateY(0)"; e.currentTarget.style.boxShadow = "0 0 32px var(--accent-glow), 0 6px 18px rgba(124,92,255,0.4)"; }}>
                  無料ではじめる
                  <svg width="14" height="14" viewBox="0 0 24 24" fill="none"><path d="M5 12h14m-6-6l6 6-6 6" stroke="white" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"/></svg>
                </button>
              </div>
              <div className="mono" style={{ fontSize: 9.5, color: "var(--text-mute)", letterSpacing: 0.06 }}>
                ※登録のみ、個人情報は厳重に管理します。
              </div>
            </form>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─── AI CONSOLE PREVIEW ─────────────────────────────────────────
function AIConsoleSection() {
  const liveCV = "128,940";
  return (
    <section style={{ padding: "16px 0 32px", position: "relative" }}>
      <div className="wrap">
        <div style={{ textAlign: "center", maxWidth: 880, marginInline: "auto", marginBottom: 28 }}>
          <div className="mono" style={{ fontSize: 11, color: "var(--accent-2)", letterSpacing: 0.2, textTransform: "uppercase", marginBottom: 10 }}>AI Console preview</div>
          <h2 className="display" style={{ fontSize: "clamp(26px, 4.2vw, 40px)", fontWeight: 700, margin: 0, letterSpacing: -0.025, lineHeight: 1.2 }}>
            自然言語で、<br />計測の全部を動かす。
          </h2>
          <p style={{ fontSize: 14.5, color: "var(--text-mid)", marginTop: 16, lineHeight: 1.7, maxWidth: 640, marginInline: "auto" }}>
            ダッシュボードを開かずに、AI へ指示するだけで計測が動く。<br />
            CV 集計・媒体送信・ LTV 分析、ぜんぶ会話で完結。
          </p>
        </div>
        <div className="hero-mock" style={{ position: "relative", maxWidth: 1100, marginInline: "auto" }}>
          <div style={{
            position: "absolute", inset: -40, background: "radial-gradient(ellipse at 50% 50%, var(--accent-glow), transparent 70%)",
            pointerEvents: "none", filter: "blur(40px)",
          }} />
          <div style={{
            position: "relative",
            background: "var(--bg-1)", border: "1px solid var(--border-strong)",
            borderRadius: 18, overflow: "hidden",
            boxShadow: "0 40px 100px -20px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.04)",
          }}>
            <div style={{ display: "flex", alignItems: "center", gap: 10, padding: "12px 18px", background: "var(--bg-2)", borderBottom: "1px solid var(--border)" }}>
              <span style={{ width: 11, height: 11, borderRadius: 6, background: "#FF5F57" }} />
              <span style={{ width: 11, height: 11, borderRadius: 6, background: "#FEBC2E" }} />
              <span style={{ width: 11, height: 11, borderRadius: 6, background: "#28C840" }} />
              <div className="mono" style={{ flex: 1, textAlign: "center", fontSize: 11, color: "var(--text-mute)" }}>
                <span style={{ color: "var(--success)" }}>●</span> app.urlapi.me/dashboard
              </div>
            </div>
            <div className="hero-mock-grid" style={{ display: "grid", gridTemplateColumns: "1.3fr 1fr", minHeight: 480 }}>
              <div style={{ padding: "24px 28px", borderRight: "1px solid var(--border)", display: "flex", flexDirection: "column", gap: 16 }}>
                <div className="mono" style={{ fontSize: 10, color: "var(--text-mute)", letterSpacing: 0.12 }}>AI CONSOLE · sonnet-4.5</div>
                <div style={{ display: "flex", gap: 12 }}>
                  <div style={{ width: 26, height: 26, borderRadius: 6, background: "var(--bg-3)", display: "grid", placeItems: "center", fontSize: 11, fontWeight: 700, color: "var(--text)", flexShrink: 0 }}>9</div>
                  <div style={{ fontSize: 13.5, color: "var(--text-mid)", borderLeft: "2px solid var(--accent)", paddingLeft: 12 }}>
                    Instagram 経由の顧客の LTV、他チャネルと比べて高い?
                  </div>
                </div>
                <div style={{ display: "flex", gap: 12 }}>
                  <div style={{ width: 26, height: 26, borderRadius: 6, background: "linear-gradient(135deg, var(--accent), var(--accent-2))", display: "grid", placeItems: "center", flexShrink: 0 }}>
                    <I.Logo size={13} color="#0A0A0A" />
                  </div>
                  <div style={{ flex: 1, display: "flex", flexDirection: "column", gap: 10 }}>
                    {[
                      { tool: "query_clicks", arg: '{ source: "instagram" }' },
                      { tool: "join_orders",  arg: '{ window: "180d" }' },
                      { tool: "compute_ltv",  arg: '{ groupby: "source" }' },
                    ].map((t, i) => (
                      <div key={i} style={{ background: "var(--bg-2)", border: "1px solid var(--border)", borderRadius: 6, padding: "5px 10px", display: "flex", alignItems: "center", gap: 8, fontSize: 11 }}>
                        <I.Check size={11} style={{ color: "var(--success)" }} />
                        <span className="mono" style={{ color: "var(--accent)" }}>{t.tool}</span>
                        <span className="mono" style={{ color: "var(--text-mute)" }}>{t.arg}</span>
                      </div>
                    ))}
                    <div style={{ fontSize: 13.5, color: "var(--text)", lineHeight: 1.65 }}>
                      Instagram 経由は <strong style={{ color: "var(--success)" }}>LTV ¥18,420</strong>で全体平均より <strong style={{ color: "var(--success)" }}>+42%</strong>。<br />
                      リピート率も <strong style={{ color: "var(--success)" }}>+31%</strong> で群を抜いています。広告予算を <span className="mono" style={{ color: "var(--accent)", padding: "1px 5px", background: "var(--accent-soft)", borderRadius: 3 }}>+20%</span> 振り替える提案を作りますか?
                    </div>
                    <div style={{ display: "flex", gap: 8, marginTop: 4 }}>
                      <button style={{ padding: "6px 10px", background: "var(--accent)", color: "white", border: "none", borderRadius: 5, fontSize: 11.5, fontWeight: 500, cursor: "pointer" }}>予算配分を提案</button>
                      <button style={{ padding: "6px 10px", background: "transparent", color: "var(--text-mid)", border: "1px solid var(--border)", borderRadius: 5, fontSize: 11.5, cursor: "pointer" }}>詳細を見る</button>
                    </div>
                  </div>
                </div>
                <div style={{ flex: 1 }} />
                <div style={{ background: "var(--bg-2)", border: "1px solid var(--border-strong)", borderRadius: 10, padding: "8px 8px 8px 14px", display: "flex", alignItems: "center", gap: 8, boxShadow: "0 0 0 3px var(--accent-soft)" }}>
                  <span style={{ flex: 1, fontSize: 13, color: "var(--text-mute)" }}>Ask anything…<span style={{ display: "inline-block", width: 1, height: 14, background: "var(--accent)", marginLeft: 2, animation: "blink 1s infinite", verticalAlign: "middle" }} /></span>
                  <span className="mono" style={{ fontSize: 10, color: "var(--text-mute)", padding: "2px 5px", background: "var(--bg-3)", border: "1px solid var(--border)", borderRadius: 3 }}>⌘K</span>
                  <button style={{ width: 28, height: 28, background: "var(--accent)", border: "none", borderRadius: 6, color: "white", display: "grid", placeItems: "center" }}>
                    <I.ArrowUp size={13} />
                  </button>
                </div>
              </div>
              <div className="hero-mock-right" style={{ padding: "24px 24px", display: "flex", flexDirection: "column", gap: 14, background: "var(--bg-1)" }}>
                <div className="mono" style={{ fontSize: 10, color: "var(--text-mute)", letterSpacing: 0.12 }}>LIVE</div>
                <div>
                  <div className="mono" style={{ fontSize: 10, color: "var(--text-mute)", textTransform: "uppercase", letterSpacing: 0.1 }}>TOTAL CLICKS · LAST 30D</div>
                  <div className="display hero-mock-headline" style={{ fontSize: 42, fontWeight: 700, marginTop: 4, letterSpacing: -0.02 }}>{liveCV}</div>
                  <div style={{ display: "flex", alignItems: "center", gap: 6, marginTop: 2 }}>
                    <I.Up size={11} style={{ color: "var(--success)" }} />
                    <span className="mono" style={{ fontSize: 11, color: "var(--success)" }}>+24.6%</span>
                    <span className="mono" style={{ fontSize: 10, color: "var(--text-mute)" }}>vs prev 30d</span>
                  </div>
                </div>
                <div style={{ height: 90, position: "relative" }}>
                  <svg width="100%" height="100%" viewBox="0 0 280 90" preserveAspectRatio="none">
                    <defs>
                      <linearGradient id="hg" x1="0" y1="0" x2="0" y2="1">
                        <stop offset="0%" stopColor="var(--accent)" stopOpacity="0.5" />
                        <stop offset="100%" stopColor="var(--accent)" stopOpacity="0" />
                      </linearGradient>
                    </defs>
                    {(() => {
                      const pts = [50,52,48,58,62,55,70,68,72,80,78,82,75,88];
                      const max = Math.max(...pts), min = Math.min(...pts) - 5;
                      const path = pts.map((p, i) => `${i === 0 ? 'M' : 'L'} ${(i / (pts.length-1)) * 280} ${90 - ((p - min) / (max - min)) * 80}`).join(" ");
                      return (
                        <>
                          <path d={`${path} L 280 90 L 0 90 Z`} fill="url(#hg)" />
                          <path d={path} fill="none" stroke="var(--accent)" strokeWidth="1.8" />
                        </>
                      );
                    })()}
                  </svg>
                </div>
                <div className="mono" style={{ fontSize: 10, color: "var(--text-mute)", textTransform: "uppercase", letterSpacing: 0.1 }}>CV送信状況</div>
                <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 6 }}>
                  {[
                    { n: "Meta",   v: "847" },
                    { n: "Google", v: "293" },
                    { n: "TikTok", v: "164" },
                    { n: "LINE",   v: "65"  },
                  ].map((p, i) => {
                    const ent = BRAND[p.n];
                    const L = ent ? ent.L : null;
                    return (
                      <div key={i} style={{ padding: "8px 10px", background: "var(--bg-2)", border: "1px solid var(--border)", borderRadius: 6, display: "flex", alignItems: "center", gap: 8 }}>
                        {L ? <L size={18} /> : null}
                        <span style={{ fontSize: 11, fontWeight: 500, flex: 1 }}>{p.n}</span>
                        <span className="mono" style={{ fontSize: 11, color: "var(--text-mid)" }}>{p.v}</span>
                        <I.Check size={10} style={{ color: "var(--success)" }} />
                      </div>
                    );
                  })}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

// ─── INLINE CTA STRIP ───────────────────────────────────────────
function InlineCTA({ headline = "いますぐ無料ではじめる。", sub = "あなたの AI を urlapi に紹介するところから。クレカ登録なし。" } = {}) {
  return (
    <section style={{ padding: "12px 24px", position: "relative" }}>
      <div className="wrap" style={{ position: "relative" }}>
        <div style={{
          display: "flex", alignItems: "center", justifyContent: "space-between", gap: 20,
          padding: "18px 24px",
          background: "linear-gradient(135deg, rgba(124,92,255,0.10), rgba(168,139,255,0.04))",
          border: "1px solid var(--accent-soft)",
          borderRadius: 14,
          flexWrap: "wrap",
          boxShadow: "0 0 40px rgba(124,92,255,0.10)",
        }}>
          <div style={{ flex: 1, minWidth: 260 }}>
            <div className="display" style={{ fontSize: 20, fontWeight: 700, letterSpacing: -0.01 }}>{headline}</div>
            <div style={{ fontSize: 13, color: "var(--text-mid)", marginTop: 4, lineHeight: 1.55 }}>{sub}</div>
          </div>
          <a href="/app/signup" style={{
            padding: "12px 22px",
            background: "linear-gradient(135deg, var(--accent), var(--accent-2))",
            color: "white",
            border: "none", borderRadius: 9, fontSize: 13.5, fontWeight: 600,
            display: "inline-flex", alignItems: "center", gap: 8,
            textDecoration: "none",
            boxShadow: "0 0 24px var(--accent-glow)",
          }}>
            無料ではじめる <I.Right size={11} />
          </a>
        </div>
      </div>
    </section>
  );
}

// ─── SCROLL-TO-TOP FAB ─────────────────────────────────────────
function ScrollToTop() {
  const [show, setShow] = lpUseState(false);
  lpUseEffect(() => {
    const onScroll = () => setShow(window.scrollY > 600);
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, []);
  return (
    <button
      aria-label="ページ上部へ"
      onClick={() => window.scrollTo({ top: 0, behavior: "smooth" })}
      style={{
        position: "fixed", bottom: 24, right: 24, zIndex: 60,
        width: 44, height: 44, borderRadius: "50%",
        background: "linear-gradient(135deg, var(--accent), var(--accent-2))",
        border: "none", cursor: "pointer", color: "white",
        display: show ? "grid" : "none",
        placeItems: "center",
        boxShadow: "0 0 28px var(--accent-glow), 0 8px 20px rgba(0,0,0,0.4)",
        transition: "transform .15s ease",
      }}
      onMouseEnter={e => e.currentTarget.style.transform = "translateY(-2px)"}
      onMouseLeave={e => e.currentTarget.style.transform = "translateY(0)"}
    >
      <svg width="18" height="18" viewBox="0 0 24 24" fill="none"><path d="M12 19V5m-7 7l7-7 7 7" stroke="white" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" /></svg>
    </button>
  );
}

// ─── CAPABILITIES (numbered editorial list, no cards) ────────
function Capabilities() {
  const items = [
    {
      icon: "tag",
      title: "タグ管理を、AIに任せる",
      desc: "「GA4 設定して、Meta CAPI も繋げて」と指示するだけ。壊れにくいタグ環境を AI が構築し、自動診断・自動修復で維持します。",
    },
    {
      icon: "url",
      title: "短縮URLを、指示するだけで生成",
      desc: "「春のセール用、Instagram で5本」と一言。UTM・CV計測・キャンペーン分類まで AI が一発でセットアップ。",
    },
    {
      icon: "data",
      title: "データ管理も、AI が代行",
      desc: "バラバラの CV、欠損、媒体間乖離。AI が継続的に診断し、整えた信号を広告 AI と MCP エージェントへ折り返します。",
    },
    {
      icon: "ltv",
      title: "LTV を、流入元から可視化",
      desc: "「Instagram DM 経由のお客さん、LTV 高い？」と聞くだけ。クリック起点で顧客の旅路を全部追えます。",
    },
    {
      icon: "ads",
      title: "広告連携、標準装備",
      desc: "Meta CAPI / Google Enhanced CV / LINE / TikTok。コードを書かず、AI が認証・ハッシュ化・送信まで自動で。",
    },
    {
      icon: "report",
      title: "レポートを、見ない時代へ",
      desc: "ダッシュボードを開くな。AI に聞け。「今週やばいやつあった？」── 判断に必要な答えが一瞬で返ります。",
    },
  ];
  return (
    <section style={{ padding: "16px 0 32px", position: "relative" }}>
      <div className="wrap">
        <div style={{ textAlign: "center", maxWidth: 880, marginInline: "auto", marginBottom: 28 }}>
          <div className="mono" style={{ fontSize: 11, color: "var(--accent-2)", letterSpacing: 0.2, textTransform: "uppercase", marginBottom: 10 }}>Capabilities</div>
          <h2 className="display" style={{ fontSize: "clamp(26px, 4vw, 38px)", fontWeight: 700, margin: 0, letterSpacing: -0.025, lineHeight: 1.2 }}>
            タグ管理から、データ管理まで。<br />
            すべて AI が支援。
          </h2>
          <p style={{ fontSize: 14.5, color: "var(--text-mid)", marginTop: 16, lineHeight: 1.7, maxWidth: 640, marginInline: "auto" }}>
            指示するだけで、プロモーション URL が作れる。<br />
            パラメータを付ければ、顧客の LTV が流入元から見える。
          </p>
        </div>

        {/* AI Hub visualization */}
        <CapabilityHub items={items} />

        {/* 6 capability cards */}
        <div className="cap-grid" style={{
          display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 14,
          maxWidth: 1100, marginInline: "auto", marginTop: 36,
        }}>
          {items.map((it, i) => (
            <div key={i} style={{
              padding: "18px 20px 20px",
              background: "var(--bg-1)",
              border: "1px solid var(--border)",
              borderRadius: 14,
              position: "relative", overflow: "hidden",
            }}>
              <div aria-hidden style={{
                position: "absolute", top: -20, right: -20,
                width: 80, height: 80,
                background: "radial-gradient(circle, var(--accent-glow), transparent 70%)",
                filter: "blur(10px)", opacity: 0.5, pointerEvents: "none",
              }} />
              <div style={{ position: "relative", display: "flex", alignItems: "flex-start", gap: 12 }}>
                <CapIcon kind={it.icon} />
                <div style={{ flex: 1 }}>
                  <div className="mono" style={{
                    fontSize: 9.5, color: "var(--accent-2)",
                    letterSpacing: 0.18, textTransform: "uppercase",
                    fontVariantNumeric: "tabular-nums",
                  }}>
                    {String(i + 1).padStart(2, "0")}
                  </div>
                  <h3 className="display" style={{
                    fontSize: 14.5, fontWeight: 700, margin: "4px 0 0",
                    lineHeight: 1.35, color: "var(--text)", letterSpacing: -0.01,
                  }}>{it.title}</h3>
                </div>
              </div>
              <p style={{
                fontSize: 12.5, color: "var(--text-mid)",
                lineHeight: 1.65, margin: "12px 0 0",
              }}>{it.desc}</p>
            </div>
          ))}
        </div>
      </div>
      <style>{`
        @media (max-width: 880px) {
          .cap-grid { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>
  );
}

// ── Small icon set for capabilities ────────────────────
function CapIcon({ kind }) {
  const box = {
    width: 34, height: 34, borderRadius: 9,
    background: "var(--accent-soft)",
    border: "1px solid var(--accent-soft)",
    display: "grid", placeItems: "center",
    color: "var(--accent-2)",
    flexShrink: 0,
  };
  const svgs = {
    tag: <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round"><path d="M3 12V5a2 2 0 0 1 2-2h7l9 9-9 9-9-9Z"/><circle cx="8" cy="8" r="1.5" fill="currentColor"/></svg>,
    url: <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round"><path d="M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 1 0-5.66-5.66l-1 1"/><path d="M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 1 0 5.66 5.66l1-1"/></svg>,
    data: <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round"><ellipse cx="12" cy="5" rx="8" ry="3"/><path d="M4 5v14a8 3 0 0 0 16 0V5M4 12a8 3 0 0 0 16 0"/></svg>,
    ltv: <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round"><path d="M3 3v18h18M7 14l3-3 3 3 5-5"/></svg>,
    ads: <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round"><path d="M3 11v2a3 3 0 0 0 3 3l2 5 3-1-1.5-4 7-2V8L8 11H6a3 3 0 0 0-3 0Z"/></svg>,
    report: <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round"><path d="M12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"/></svg>,
  };
  return <div style={box}>{svgs[kind]}</div>;
}

// ── AI Hub — center orb with 6 capability nodes ───────
function CapabilityHub({ items }) {
  const nodes = [
    { l: "タグ",    a: -90, c: "#7C5CFF" },
    { l: "短縮URL", a: -30, c: "#A88BFF" },
    { l: "データ",  a:  30, c: "#5CC8FF" },
    { l: "LTV",     a:  90, c: "#2EE6A8" },
    { l: "広告",    a: 150, c: "#FF9A3C" },
    { l: "レポート", a: 210, c: "#FF5C7A" },
  ];
  const W = 720, H = 280;
  const cx = W / 2, cy = H / 2;
  const R = 110;
  return (
    <div style={{
      position: "relative", maxWidth: 720, marginInline: "auto",
      padding: "20px 0",
    }}>
      {/* outer glow */}
      <div aria-hidden style={{
        position: "absolute", inset: 0,
        background: "radial-gradient(ellipse at 50% 50%, var(--accent-glow), transparent 70%)",
        filter: "blur(40px)", pointerEvents: "none",
      }} />

      <svg viewBox={`0 0 ${W} ${H}`} width="100%" height={H} style={{ position: "relative", display: "block" }}>
        <defs>
          <radialGradient id="hub-core" cx="50%" cy="50%" r="50%">
            <stop offset="0%" stopColor="#FFFFFF" stopOpacity="0.95" />
            <stop offset="40%" stopColor="#A88BFF" stopOpacity="0.9" />
            <stop offset="100%" stopColor="#7C5CFF" stopOpacity="0.4" />
          </radialGradient>
          <linearGradient id="hub-line" x1="0" y1="0" x2="1" y2="0">
            <stop offset="0%" stopColor="var(--accent)" stopOpacity="0.0" />
            <stop offset="50%" stopColor="var(--accent-2)" stopOpacity="0.7" />
            <stop offset="100%" stopColor="var(--accent)" stopOpacity="0.0" />
          </linearGradient>
        </defs>

        {/* Orbit rings */}
        <circle cx={cx} cy={cy} r={R - 18} fill="none" stroke="var(--border)" strokeWidth="1" strokeDasharray="2 3" opacity="0.6" />
        <circle cx={cx} cy={cy} r={R + 32} fill="none" stroke="var(--border)" strokeWidth="1" strokeDasharray="2 3" opacity="0.4" />

        {/* Connection lines + traveling dots */}
        {nodes.map((n, i) => {
          const rad = (n.a * Math.PI) / 180;
          const x = cx + Math.cos(rad) * R;
          const y = cy + Math.sin(rad) * R;
          return (
            <g key={i}>
              <line x1={cx} y1={cy} x2={x} y2={y}
                stroke="var(--accent-soft)" strokeWidth="1.5"
                opacity="0.6" strokeDasharray="3 4" />
              {/* traveling dot */}
              <circle r="2.5" fill={n.c} opacity="0.85">
                <animateMotion
                  dur={`${2 + (i * 0.3)}s`}
                  repeatCount="indefinite"
                  path={`M ${cx} ${cy} L ${x} ${y}`}
                />
              </circle>
            </g>
          );
        })}

        {/* Nodes */}
        {nodes.map((n, i) => {
          const rad = (n.a * Math.PI) / 180;
          const x = cx + Math.cos(rad) * R;
          const y = cy + Math.sin(rad) * R;
          return (
            <g key={i}>
              <circle cx={x} cy={y} r="22" fill="var(--bg-1)" stroke={n.c} strokeWidth="1.5" opacity="0.95" />
              <circle cx={x} cy={y} r="22" fill="none" stroke={n.c} strokeWidth="3" opacity="0.25">
                <animate attributeName="r" values="22;28;22" dur={`${2 + i * 0.2}s`} repeatCount="indefinite" />
                <animate attributeName="opacity" values="0.25;0;0.25" dur={`${2 + i * 0.2}s`} repeatCount="indefinite" />
              </circle>
              <text x={x} y={y + 1} textAnchor="middle" dominantBaseline="middle"
                fill="var(--text)"
                style={{ fontFamily: "var(--font-sans)", fontSize: 11, fontWeight: 600 }}>
                {n.l}
              </text>
              {/* index pill */}
              <g transform={`translate(${x + 16}, ${y - 22})`}>
                <rect x="-9" y="-7" width="18" height="14" rx="3" fill={n.c} opacity="0.85" />
                <text x="0" y="1" textAnchor="middle" dominantBaseline="middle"
                  fill="#06060A"
                  style={{ fontFamily: "var(--font-mono)", fontSize: 8.5, fontWeight: 700 }}>
                  {String(i + 1).padStart(2, "0")}
                </text>
              </g>
            </g>
          );
        })}

        {/* Center orb */}
        <circle cx={cx} cy={cy} r="42" fill="var(--bg-0)" />
        <circle cx={cx} cy={cy} r="36" fill="url(#hub-core)" opacity="0.95" />
        <circle cx={cx} cy={cy} r="50" fill="none" stroke="var(--accent)" strokeWidth="1" opacity="0.35">
          <animate attributeName="r" values="42;58;42" dur="3s" repeatCount="indefinite" />
          <animate attributeName="opacity" values="0.4;0;0.4" dur="3s" repeatCount="indefinite" />
        </circle>
        <text x={cx} y={cy - 4} textAnchor="middle" dominantBaseline="middle"
          fill="#0A0A0A"
          style={{ fontFamily: "var(--font-display)", fontSize: 16, fontWeight: 800, letterSpacing: -0.01 }}>
          AI
        </text>
        <text x={cx} y={cy + 11} textAnchor="middle" dominantBaseline="middle"
          fill="#0A0A0A"
          style={{ fontFamily: "var(--font-mono)", fontSize: 7.5, fontWeight: 600, letterSpacing: 0.12 }}>
          HUB
        </text>
      </svg>

      {/* caption */}
      <div className="mono" style={{
        textAlign: "center",
        fontSize: 10.5, color: "var(--text-mute)",
        letterSpacing: 0.14, textTransform: "uppercase",
        marginTop: -6,
      }}>
        1つのAIが、6つの領域を同時に動かす
      </div>
    </div>
  );
}

window.Nav = Nav;
window.Hero = Hero;
window.AIConsoleSection = AIConsoleSection;
window.Capabilities = Capabilities;
window.InlineCTA = InlineCTA;
window.ScrollToTop = ScrollToTop;
