// shiwake LP — sections
const { useState, useEffect } = React;

/* ────────────────────────────────────────────────────────────────
   NAV
   ──────────────────────────────────────────────────────────────── */
function Nav() {
  const [scrolled, setScrolled] = useState(false);
  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 12);
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, []);
  return (
    <nav className={`nav ${scrolled ? "scrolled" : ""}`}>
      <div className="wrap nav-inner">
        <div className="logo">
          shiwake <small>シワケ</small>
        </div>
        <div className="nav-links">
          <a href="#pain" className="hide-sm">記録地獄</a>
          <a href="#no-keyboard" className="hide-sm">脱キーボード</a>
          <a href="#assistant" className="hide-sm">アシスタント</a>
          <a href="#compare" className="hide-sm">比較</a>
          <a href="https://forms.gle/ioqz5yyNJsgLfi44A" target="_blank" rel="noopener noreferrer" className="btn btn-ghost" style={{padding: "8px 16px", fontSize: 12}}>α版テスト</a>
        </div>
      </div>
    </nav>
  );
}

/* ────────────────────────────────────────────────────────────────
   HERO
   ──────────────────────────────────────────────────────────────── */
function Hero() {
  return (
    <section id="hero" style={{ paddingTop: 160, paddingBottom: 120 }}>
      <div className="wrap" style={{ position: "relative" }}>
        {/* Vertical kicker on the side */}
        <div style={{
          position: "absolute",
          top: 8, right: 56,
          display: "flex", flexDirection: "column", alignItems: "center", gap: 16,
        }} className="hero-vk">
          <span className="v-kicker">FOOD &middot; WEIGHT &middot; NOTES</span>
          <span style={{ width: 1, height: 60, background: "var(--line)" }}></span>
        </div>

        <div style={{
          display: "grid",
          gridTemplateColumns: "minmax(0, 1.15fr) minmax(0, 0.85fr)",
          gap: 64,
          alignItems: "center",
        }} className="hero-grid">
          {/* Left: copy */}
          <div>
            <Reveal>
              <div className="mono" style={{ marginBottom: 28 }}>
                <span style={{ color: "var(--accent)" }}>●</span>&nbsp;&nbsp;01 — For those who quit
              </div>
            </Reveal>

            <Reveal delay={120}>
              <h1 className="serif" style={{
                fontSize: "clamp(22px, 4.6vw, 62px)",
                fontWeight: 500,
                lineHeight: 1.18,
                letterSpacing: "-0.02em",
                color: "var(--ink)",
                marginBottom: 32,
              }}>
                <span style={{ display: "block", whiteSpace: "nowrap" }}>ダイエットアプリの</span>
                <span style={{ display: "block", whiteSpace: "nowrap" }}>
                  <span style={{ fontStyle: "italic", color: "var(--accent)" }}>記録地獄</span>に挫折した方へ。
                </span>
              </h1>
            </Reveal>

            <Reveal delay={220}>
              <p style={{
                fontSize: 17,
                lineHeight: 1.85,
                color: "var(--ink-2)",
                maxWidth: 520,
                marginBottom: 40,
              }}>
                ワンタップして話すだけ、<br/>
                食事、体重、運動の記録を 5 秒で終わらせる。
              </p>
            </Reveal>

            <Reveal delay={320}>
              <div style={{ display: "flex", gap: 14, flexWrap: "wrap", alignItems: "center" }}>
                <button
                  type="button"
                  disabled
                  aria-disabled="true"
                  className="btn btn-primary"
                  style={{ opacity: 0.55, cursor: "not-allowed" }}
                  title="準備中"
                >
                  App Store でダウンロード
                  <span style={{ fontFamily: "var(--mono)", fontSize: 10, letterSpacing: "0.16em", opacity: 0.7, textTransform: "uppercase" }}>準備中</span>
                </button>
                <a href="https://forms.gle/ioqz5yyNJsgLfi44A" target="_blank" rel="noopener noreferrer" className="btn btn-ghost">
                  α版のテストに参加する
                </a>
              </div>
            </Reveal>

            <Reveal delay={420}>
              <div style={{
                marginTop: 48,
                paddingTop: 28,
                borderTop: "1px solid var(--line-2)",
                display: "grid",
                gridTemplateColumns: "repeat(3, 1fr)",
                gap: 24,
                maxWidth: 520,
              }}>
                <KeyStat n="5" unit="秒" label="記録までの所要" />
                <KeyStat n="1" unit="タップ" label="入力に必要な操作" />
                <KeyStat n="0" unit="キー入力" label="キーボードに戻らない" />
              </div>
            </Reveal>
          </div>

          {/* Right: phone mockup with Camera UI */}
          <Reveal delay={200}>
            <div style={{ position: "relative", maxWidth: 360, marginLeft: "auto" }}>
              <div className="mono-sm" style={{ marginBottom: 14, textAlign: "right" }}>
                fig. 01 — app interface
              </div>
              <div className="phone-shell">
                <div className="phone-notch"></div>
                <div className="phone-screen">
                  <CameraScreen />
                </div>
              </div>
            </div>
          </Reveal>
        </div>
      </div>

      <style>{`
        @media (max-width: 900px) {
          .hero-grid { grid-template-columns: 1fr !important; gap: 48px !important; }
          .hero-vk { display: none !important; }
        }
      `}</style>
    </section>
  );
}

function KeyStat({ n, unit, label }) {
  const [ref, val] = useCountUp(parseInt(n, 10), 1400);
  return (
    <div ref={ref}>
      <div style={{ display: "flex", alignItems: "baseline", gap: 4 }}>
        <span className="serif" style={{
          fontSize: 40, fontWeight: 500, lineHeight: 1, letterSpacing: "-0.02em", color: "var(--ink)",
        }}>{Math.round(val)}</span>
        <span className="mono" style={{ fontSize: 11, color: "var(--ink-2)" }}>{unit}</span>
      </div>
      <div className="mono-sm" style={{ marginTop: 6 }}>{label}</div>
    </div>
  );
}

/* ────────────────────────────────────────────────────────────────
   FEATURES
   ──────────────────────────────────────────────────────────────── */
function Features() {
  const items = [
    {
      n: "01",
      en: "Zero-tap capture",
      jp: "起動ゼロタップ、3 秒で記録。",
      body: "ホーム画面のウィジェットから話しかければ、アプリを開かなくても記録が走る。ロックを解除してから入力欄を探す、あの 10 秒がまるごと消える。",
      meta: "Widget &middot; Lock screen &middot; Shortcuts",
    },
    {
      n: "02",
      en: "AI sorts the murmur",
      jp: "雑談を、AI が仕訳ける。",
      body: "「やよい軒で唐揚げ定食、体重 67.8、ちょっと食べすぎた」。そんな一文を、食事・体重・メモの 3 つに自動で分けて、それぞれの正しい場所に保存。",
      meta: "Meals &middot; Weights &middot; Notes",
    },
    {
      n: "03",
      en: "Hard menus, solved",
      jp: "難しいメニューも、正確に。",
      body: "ラーメン二郎マシマシ。コンビニの新作スイーツ。チェーン店の期間限定。Web 検索を使ってカロリーと栄養素を毎回ちゃんと拾いに行く。",
      meta: "Web search &middot; Chain menus &middot; Convenience",
    },
    {
      n: "04",
      en: "Quiet by design",
      jp: "急かさない、責めない。",
      body: "通知も、連続記録のカウントも、ない。ダイエットは習慣であって試験じゃない。続けたい日に開けば、ちゃんとそこにある日記。",
      meta: "No streaks &middot; No nags &middot; No shame",
    },
  ];

  return (
    <section id="features" style={{ background: "var(--bg)" }}>
      <div className="wrap">
        <Reveal>
          <div className="mono" style={{ marginBottom: 18 }}>02 — Features &nbsp;/&nbsp; 主な機能</div>
        </Reveal>
        <Reveal delay={120}>
          <h2 className="serif" style={{
            fontSize: "clamp(34px, 4vw, 56px)",
            fontWeight: 500,
            lineHeight: 1.18,
            letterSpacing: "-0.015em",
            maxWidth: 820,
            marginBottom: 72,
            textWrap: "pretty",
          }}>
            記録までに必要な動線を、<br/>
            徹底して省略。
          </h2>
        </Reveal>

        <div style={{
          display: "grid",
          gridTemplateColumns: "repeat(2, 1fr)",
          rowGap: 12, columnGap: 56,
        }} className="feat-grid">
          {items.map((it, i) => (
            <Reveal key={it.n} delay={i * 80}>
              <FeatureItem {...it} />
            </Reveal>
          ))}
        </div>
      </div>

      <style>{`
        @media (max-width: 820px) {
          .feat-grid { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>
  );
}

function FeatureItem({ n, en, jp, body, meta }) {
  return (
    <article style={{
      borderTop: "1px solid var(--line-2)",
      padding: "36px 0 44px",
      display: "grid",
      gridTemplateColumns: "64px 1fr",
      gap: 8,
      alignItems: "start",
    }}>
      <div className="mono" style={{ paddingTop: 6, color: "var(--accent)" }}>{n}</div>
      <div>
        <div className="mono-sm" style={{ marginBottom: 10 }}>{en}</div>
        <h3 className="serif" style={{
          fontSize: 28,
          fontWeight: 500,
          letterSpacing: "-0.01em",
          lineHeight: 1.3,
          marginBottom: 14,
          color: "var(--ink)",
        }}>{jp}</h3>
        <p style={{ color: "var(--ink-2)", fontSize: 15, lineHeight: 1.85, marginBottom: 18, maxWidth: 480 }}>
          {body}
        </p>
        <div className="mono-sm" dangerouslySetInnerHTML={{ __html: meta }} />
      </div>
    </article>
  );
}

/* ────────────────────────────────────────────────────────────────
   A DAY WITH SHIWAKE
   ──────────────────────────────────────────────────────────────── */
function Day() {
  const moments = [
    {
      time: "07:42",
      label: "Morning",
      jp: "朝、駅のホームで",
      utter: "「コンビニのおにぎり 2 個と、無糖ラテ」",
      action: "メニュー検索 → 食事カードに 2 件追加。",
    },
    {
      time: "08:10",
      label: "Weigh-in",
      jp: "通勤の途中、ふと",
      utter: "「今日の朝、体重 67.4 だった」",
      action: "体重カードに 67.4 kg を記録、前日比 −0.2 を計算。",
    },
    {
      time: "12:33",
      label: "Lunch",
      jp: "昼休み、社食で",
      utter: "「やよい軒、唐揚げ定食」",
      action: "チェーン店メニューを参照、約 1,020 kcal を仕訳。",
    },
    {
      time: "19:48",
      label: "Hard menu",
      jp: "ジムのあと、二郎で",
      utter: "「ラーメン二郎、小ラーメン、ニンニク・ヤサイマシ」",
      action: "Web 検索で実カロリーを推定、注釈付きで保存。",
    },
    {
      time: "23:15",
      label: "Note",
      jp: "寝る前、ベッドで",
      utter: "「今日ちょっと食べすぎた。明日は控えめにしたい」",
      action: "メモに分類、明日の朝のリマインダーに紐付け。",
    },
  ];

  return (
    <section id="day" style={{ background: "var(--bg-2)" }}>
      <div className="wrap">
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 48, marginBottom: 72 }} className="day-head">
          <Reveal>
            <div>
              <div className="mono" style={{ marginBottom: 18 }}>06 — A day with shiwake</div>
              <h2 className="serif" style={{
                fontSize: "clamp(34px, 4vw, 56px)",
                fontWeight: 500,
                lineHeight: 1.18,
                letterSpacing: "-0.015em",
                textWrap: "pretty",
              }}>
                ある減量中の<br/>火曜日の、5 つの瞬間。
              </h2>
            </div>
          </Reveal>
          <Reveal delay={120}>
            <p style={{ color: "var(--ink-2)", fontSize: 15, lineHeight: 1.85, maxWidth: 460, paddingTop: 32 }}>
              シワケは「記録する時間」を作りません。
              通勤のホームで。昼休みの食堂で。寝る前のベッドで。
              ふと口をついて出た一言を、その場で受け取って、後で見返せる形に整えます。
            </p>
          </Reveal>
        </div>

        <div style={{ position: "relative" }}>
          {/* timeline */}
          <div style={{
            position: "absolute", top: 0, bottom: 0, left: 110,
            width: 1, background: "var(--line)",
          }} className="day-line"></div>

          {moments.map((m, i) => (
            <Reveal key={i} delay={i * 60}>
              <div style={{
                display: "grid",
                gridTemplateColumns: "110px 1fr",
                gap: 0,
                padding: "28px 0",
                borderBottom: i < moments.length - 1 ? "1px solid var(--line-2)" : "none",
              }} className="day-row">
                <div style={{ paddingTop: 4 }}>
                  <div className="mono" style={{ color: "var(--accent)" }}>{m.time}</div>
                  <div className="mono-sm" style={{ marginTop: 4 }}>{m.label}</div>
                </div>
                <div style={{ position: "relative", paddingLeft: 32 }}>
                  <span style={{
                    position: "absolute", left: -4, top: 10,
                    width: 9, height: 9, borderRadius: "50%",
                    background: "var(--bg-2)", border: "1px solid var(--accent)",
                  }}></span>
                  <div className="mono-sm" style={{ marginBottom: 6 }}>{m.jp}</div>
                  <p className="serif" style={{
                    fontSize: 22, lineHeight: 1.5, fontWeight: 400,
                    color: "var(--ink)", marginBottom: 10, fontStyle: "italic",
                  }}>{m.utter}</p>
                  <p style={{ fontSize: 14, color: "var(--ink-2)", lineHeight: 1.7 }}>
                    <span className="mono-sm" style={{ marginRight: 8 }}>→</span>
                    {m.action}
                  </p>
                </div>
              </div>
            </Reveal>
          ))}
        </div>
      </div>

      <style>{`
        @media (max-width: 720px) {
          .day-head { grid-template-columns: 1fr !important; }
          .day-row { grid-template-columns: 80px 1fr !important; }
          .day-line { left: 80px !important; }
        }
      `}</style>
    </section>
  );
}

/* ────────────────────────────────────────────────────────────────
   AI SORTING DEMO
   ──────────────────────────────────────────────────────────────── */
function AI() {
  const cards = [
    {
      label: "Meals",
      jp: "食事",
      items: [
        { k: "やよい軒 唐揚げ定食", v: "≈ 1,020 kcal" },
        { k: "ライス", v: "おかわり ×1" },
      ],
      tone: "var(--accent)",
    },
    {
      label: "Weights",
      jp: "体重",
      items: [
        { k: "本日 朝", v: "67.8 kg" },
        { k: "前日比", v: "+0.1 kg" },
      ],
      tone: "var(--ink)",
    },
    {
      label: "Notes",
      jp: "メモ",
      items: [
        { k: "気分", v: "ちょっと食べすぎた" },
        { k: "明日", v: "控えめにしたい" },
      ],
      tone: "var(--ink-2)",
    },
  ];

  return (
    <section id="ai" style={{ background: "var(--bg)" }}>
      <div className="wrap">
        <Reveal>
          <div className="mono" style={{ marginBottom: 18 }}>07 — How the AI sorts</div>
        </Reveal>
        <Reveal delay={120}>
          <h2 className="serif" style={{
            fontSize: "clamp(34px, 4vw, 56px)",
            fontWeight: 500,
            lineHeight: 1.18,
            letterSpacing: "-0.015em",
            maxWidth: 880,
            marginBottom: 18,
            textWrap: "pretty",
          }}>
            ひとつのつぶやきを、<br/>3 つの場所へ。
          </h2>
        </Reveal>
        <Reveal delay={200}>
          <p style={{ color: "var(--ink-2)", fontSize: 15, lineHeight: 1.85, maxWidth: 540, marginBottom: 72 }}>
            "仕訳" は会計の用語で、ひとつの出来事を勘定科目に分けて記す作業のこと。シワケはそれを、毎日のごはんや体重に対してやります。
          </p>
        </Reveal>

        <Reveal delay={240}>
          <div style={{
            display: "grid",
            gridTemplateColumns: "1fr auto 1fr",
            alignItems: "center",
            gap: 56,
            marginBottom: 24,
          }} className="ai-grid">
            {/* Input */}
            <div>
              <div className="mono-sm" style={{ marginBottom: 12 }}>Input — つぶやき</div>
              <div className="card" style={{ padding: "28px 28px", position: "relative" }}>
                <span className="mono-sm" style={{ position: "absolute", top: 14, right: 16, color: "var(--ink-3)" }}>23:08</span>
                <p className="serif" style={{ fontSize: 22, lineHeight: 1.55, fontStyle: "italic", color: "var(--ink)" }}>
                  「今日やよい軒で唐揚げ定食食べた。体重 67.8 だった。ちょっと食べすぎたかも、明日は控えめにしたい。」
                </p>
              </div>
            </div>

            {/* Arrow */}
            <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: 12 }} className="ai-arrow">
              <span className="mono-sm">AI sorts</span>
              <svg width="48" height="24" viewBox="0 0 48 24" fill="none">
                <path d="M2 12 H42 M34 4 L42 12 L34 20" stroke="var(--accent)" strokeWidth="1.4" fill="none" strokeLinecap="round" strokeLinejoin="round"/>
              </svg>
              <span className="mono-sm" style={{ color: "var(--accent)" }}>3 categories</span>
            </div>

            {/* Output */}
            <div>
              <div className="mono-sm" style={{ marginBottom: 12 }}>Output — 仕訳結果</div>
              <div style={{ display: "grid", gap: 12 }}>
                {cards.map((c) => (
                  <div key={c.label} className="card" style={{ padding: "16px 18px" }}>
                    <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: 10 }}>
                      <div style={{ display: "flex", alignItems: "center", gap: 10 }}>
                        <span style={{ width: 6, height: 6, borderRadius: "50%", background: c.tone, display: "inline-block" }}></span>
                        <span className="mono-sm" style={{ color: "var(--ink)" }}>{c.label}</span>
                        <span className="serif" style={{ fontSize: 14, color: "var(--ink-2)" }}>／ {c.jp}</span>
                      </div>
                    </div>
                    {c.items.map((it, i) => (
                      <div key={i} style={{
                        display: "flex", justifyContent: "space-between",
                        fontSize: 13, padding: "4px 0",
                        borderTop: i === 0 ? "none" : "1px dashed var(--line-2)",
                      }}>
                        <span style={{ color: "var(--ink-2)" }}>{it.k}</span>
                        <span className="serif" style={{ color: "var(--ink)" }}>{it.v}</span>
                      </div>
                    ))}
                  </div>
                ))}
              </div>
            </div>
          </div>
        </Reveal>

        {/* Hard menu note */}
        <Reveal delay={120}>
          <div style={{
            marginTop: 64, padding: "32px 36px",
            borderTop: "1px solid var(--line-2)",
            display: "grid", gridTemplateColumns: "180px 1fr 1fr", gap: 36, alignItems: "start",
          }} className="hard-row">
            <div>
              <div className="mono" style={{ color: "var(--accent)" }}>※ note</div>
              <div className="mono-sm" style={{ marginTop: 6 }}>Hard menus</div>
            </div>
            <p className="serif" style={{ fontSize: 20, lineHeight: 1.55, color: "var(--ink)" }}>
              「ラーメン二郎マシマシ」も、コンビニの新作スイーツも、AI が Web を見に行って実カロリーを推定する。
            </p>
            <p style={{ fontSize: 14, color: "var(--ink-2)", lineHeight: 1.85 }}>
              一般的な栄養素データベースに載っていない、ローカルチェーンや期間限定メニュー、トッピング豊富な丼など。曖昧な記録のままにせず、出典付きの推定値で残します。
            </p>
          </div>
        </Reveal>
      </div>

      <style>{`
        @media (max-width: 900px) {
          .ai-grid { grid-template-columns: 1fr !important; gap: 24px !important; }
          .ai-arrow { flex-direction: row !important; }
          .ai-arrow svg { transform: rotate(90deg); }
          .hard-row { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>
  );
}

/* ────────────────────────────────────────────────────────────────
   GRAPH PREVIEW
   ──────────────────────────────────────────────────────────────── */
function Graph() {
  // generate a smooth weight curve trending down
  const points = [68.4, 68.5, 68.2, 67.9, 68.1, 67.8, 67.6, 67.7, 67.4, 67.2, 67.3, 67.0, 66.8, 66.9, 66.6];
  const w = 720, h = 220, pad = 32;
  const min = 66.4, max = 68.8;
  const xs = points.map((_, i) => pad + (i * (w - pad * 2)) / (points.length - 1));
  const ys = points.map((p) => pad + ((max - p) / (max - min)) * (h - pad * 2));
  const path = xs.map((x, i) => `${i === 0 ? "M" : "L"} ${x} ${ys[i]}`).join(" ");
  const area = `${path} L ${xs[xs.length - 1]} ${h - pad} L ${xs[0]} ${h - pad} Z`;

  const kcal = [1820, 2100, 1640, 1920, 1480, 2240, 1760];

  return (
    <section id="graph" style={{ background: "var(--bg)" }}>
      <div className="wrap">
        <Reveal>
          <div className="mono" style={{ marginBottom: 18 }}>08 — Graphs &amp; data</div>
        </Reveal>
        <Reveal delay={120}>
          <h2 className="serif" style={{
            fontSize: "clamp(34px, 4vw, 56px)",
            fontWeight: 500,
            lineHeight: 1.18,
            letterSpacing: "-0.015em",
            maxWidth: 880,
            marginBottom: 18,
            textWrap: "pretty",
          }}>
            続けるほど、輪郭がはっきりする。
          </h2>
        </Reveal>
        <Reveal delay={200}>
          <p style={{ color: "var(--ink-2)", fontSize: 15, lineHeight: 1.85, maxWidth: 540, marginBottom: 64 }}>
            日々のつぶやきが積み上がると、体重の傾向と摂取カロリーの相関が、淡くしかし確かに浮かび上がります。
          </p>
        </Reveal>

        {/* Weight chart */}
        <Reveal delay={240}>
          <div style={{
            border: "1px solid var(--line-2)",
            borderRadius: 8,
            padding: 32,
            background: "var(--paper)",
            marginBottom: 24,
          }}>
            <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", marginBottom: 24 }}>
              <div>
                <div className="mono-sm" style={{ marginBottom: 6 }}>Weight &middot; 体重</div>
                <div style={{ display: "flex", alignItems: "baseline", gap: 12 }}>
                  <span className="serif" style={{ fontSize: 40, fontWeight: 500, letterSpacing: "-0.02em" }}>66.6</span>
                  <span className="mono-sm">kg</span>
                  <span className="mono-sm" style={{ color: "var(--accent)" }}>− 1.8 kg / 14 days</span>
                </div>
              </div>
              <div className="mono-sm" style={{ textAlign: "right" }}>
                May 09 — May 23, 2026
              </div>
            </div>

            <svg viewBox={`0 0 ${w} ${h}`} style={{ width: "100%", height: "auto", display: "block" }}>
              {/* grid lines */}
              {[0, 1, 2, 3, 4].map((i) => {
                const y = pad + (i * (h - pad * 2)) / 4;
                return <line key={i} x1={pad} x2={w - pad} y1={y} y2={y} stroke="var(--line-2)" strokeWidth="1"/>;
              })}
              {/* area */}
              <path d={area} fill="var(--accent)" opacity="0.08" />
              {/* line */}
              <path d={path} fill="none" stroke="var(--accent)" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"/>
              {/* points */}
              {xs.map((x, i) => (
                <circle key={i} cx={x} cy={ys[i]} r={i === xs.length - 1 ? 4 : 2.2} fill={i === xs.length - 1 ? "var(--accent)" : "var(--paper)"} stroke="var(--accent)" strokeWidth="1.2"/>
              ))}
              {/* axis labels */}
              <text x={pad} y={h - 8} fontFamily="JetBrains Mono" fontSize="9" fill="var(--ink-3)" letterSpacing="1">MAY 09</text>
              <text x={w - pad} y={h - 8} textAnchor="end" fontFamily="JetBrains Mono" fontSize="9" fill="var(--ink-3)" letterSpacing="1">MAY 23</text>
            </svg>
          </div>
        </Reveal>

        {/* Kcal bar chart + stats */}
        <Reveal delay={120}>
          <div style={{ display: "grid", gridTemplateColumns: "1.5fr 1fr", gap: 16 }} className="graph-row">
            <div style={{
              border: "1px solid var(--line-2)",
              borderRadius: 8,
              padding: 32,
              background: "var(--paper)",
            }}>
              <div className="mono-sm" style={{ marginBottom: 6 }}>Daily intake &middot; 摂取カロリー</div>
              <div style={{ display: "flex", alignItems: "baseline", gap: 8, marginBottom: 28 }}>
                <span className="serif" style={{ fontSize: 32, fontWeight: 500 }}>1,851</span>
                <span className="mono-sm">kcal avg / 7d</span>
              </div>
              <div style={{ display: "grid", gridTemplateColumns: "repeat(7, 1fr)", gap: 12, alignItems: "end", height: 120 }}>
                {kcal.map((v, i) => {
                  const pct = ((v - 1200) / 1500) * 100;
                  const over = v > 2000;
                  return (
                    <div key={i} style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: 8 }}>
                      <div style={{
                        width: "100%",
                        height: `${pct}%`,
                        background: over ? "var(--accent)" : "var(--ink)",
                        opacity: over ? 1 : 0.85,
                        borderRadius: 2,
                      }}></div>
                      <span className="mono-sm" style={{ fontSize: 9 }}>
                        {["MON","TUE","WED","THU","FRI","SAT","SUN"][i]}
                      </span>
                    </div>
                  );
                })}
              </div>
            </div>

            <div style={{
              border: "1px solid var(--line-2)",
              borderRadius: 8,
              padding: 32,
              background: "var(--paper)",
              display: "flex", flexDirection: "column", justifyContent: "space-between",
            }}>
              <div>
                <div className="mono-sm" style={{ marginBottom: 14 }}>This week &middot; 今週のまとめ</div>
                <ul style={{ listStyle: "none", display: "grid", gap: 16 }}>
                  <li style={{ display: "flex", justifyContent: "space-between", borderBottom: "1px dashed var(--line-2)", paddingBottom: 12 }}>
                    <span style={{ fontSize: 13, color: "var(--ink-2)" }}>記録した食事</span>
                    <span className="serif" style={{ fontSize: 18 }}>21<span className="mono-sm">&nbsp;件</span></span>
                  </li>
                  <li style={{ display: "flex", justifyContent: "space-between", borderBottom: "1px dashed var(--line-2)", paddingBottom: 12 }}>
                    <span style={{ fontSize: 13, color: "var(--ink-2)" }}>体重の記録</span>
                    <span className="serif" style={{ fontSize: 18 }}>6<span className="mono-sm">&nbsp;回</span></span>
                  </li>
                  <li style={{ display: "flex", justifyContent: "space-between" }}>
                    <span style={{ fontSize: 13, color: "var(--ink-2)" }}>残したメモ</span>
                    <span className="serif" style={{ fontSize: 18 }}>9<span className="mono-sm">&nbsp;件</span></span>
                  </li>
                </ul>
              </div>
              <p style={{ fontSize: 12, color: "var(--ink-3)", lineHeight: 1.7, marginTop: 24 }}>
                ※ 数値はサンプル。実画面ではあなたの記録が反映されます。
              </p>
            </div>
          </div>
        </Reveal>
      </div>

      <style>{`
        @media (max-width: 820px) {
          .graph-row { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>
  );
}

/* ────────────────────────────────────────────────────────────────
   SIGNUP
   ──────────────────────────────────────────────────────────────── */
function Signup() {
  const [email, setEmail] = useState("");
  // status: 'idle' | 'sending' | 'success' | 'error'
  const [status, setStatus] = useState("idle");
  const onSubmit = async (e) => {
    e.preventDefault();
    if (!email.includes("@") || status === "sending") return;
    setStatus("sending");
    try {
      const res = await fetch("/api/waitlist", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ email, source: "lp" }),
      });
      if (!res.ok) throw new Error("request failed");
      setStatus("success");
    } catch (err) {
      setStatus("error");
    }
  };
  return (
    <section id="signup" style={{ background: "var(--bg-2)" }}>
      <div className="wrap">
        <div style={{ display: "grid", gridTemplateColumns: "1.1fr 0.9fr", gap: 64, alignItems: "center" }} className="signup-grid">
          <Reveal>
            <div>
              <div className="mono" style={{ marginBottom: 18 }}>12 — Stay in the loop</div>
              <h2 className="serif" style={{
                fontSize: "clamp(34px, 4vw, 56px)",
                fontWeight: 500,
                lineHeight: 1.18,
                letterSpacing: "-0.015em",
                marginBottom: 22,
                textWrap: "pretty",
              }}>
                公開のお知らせを、<br/>静かに、月に一度だけ。
              </h2>
              <p style={{ color: "var(--ink-2)", fontSize: 15, lineHeight: 1.85, maxWidth: 480 }}>
                ベータ募集、TestFlight 招待、リリース予定など。営業メールは送りません。いつでもワンクリックで解除できます。
              </p>
            </div>
          </Reveal>

          <Reveal delay={120}>
            <form onSubmit={onSubmit} style={{
              background: "var(--paper)",
              border: "1px solid var(--line-2)",
              borderRadius: 8,
              padding: 32,
            }}>
              <label className="mono-sm" style={{ display: "block", marginBottom: 10 }} htmlFor="email">
                Email address
              </label>
              <input
                id="email"
                type="email"
                value={email}
                onChange={(e) => { setEmail(e.target.value); if (status === "error") setStatus("idle"); }}
                placeholder="you@example.com"
                required
                disabled={status === "success"}
                style={{
                  width: "100%",
                  padding: "14px 0",
                  border: "0",
                  borderBottom: "1px solid var(--line)",
                  background: "transparent",
                  fontSize: 18,
                  fontFamily: "var(--serif)",
                  color: "var(--ink)",
                  outline: "none",
                  marginBottom: 20,
                }}
              />
              <button
                type="submit"
                disabled={status === "sending" || status === "success"}
                className="btn btn-primary"
                style={{
                  width: "100%",
                  justifyContent: "center",
                  background: status === "error" ? "var(--accent-deep)" : undefined,
                  cursor: (status === "sending" || status === "success") ? "default" : "pointer",
                  opacity: status === "sending" ? 0.7 : 1,
                }}
              >
                {status === "idle" && "登録する"}
                {status === "sending" && "送信中…"}
                {status === "success" && "リリース時にお知らせします ✓"}
                {status === "error" && "送信失敗"}
              </button>
              <p className="mono-sm" style={{ marginTop: 14, lineHeight: 1.6 }}>
                {status === "error"
                  ? "もう一度お試しください。メールアドレスを見直して再送もできます。"
                  : status === "success"
                  ? "ありがとうございます。準備ができたらご連絡します。"
                  : "By submitting, you agree to receive occasional product updates."}
              </p>
              <div style={{
                marginTop: 16, paddingTop: 14,
                borderTop: "1px dashed var(--line-2)",
                display: "flex", alignItems: "center", gap: 8,
              }}>
                <span style={{
                  width: 5, height: 5, borderRadius: "50%",
                  background: "var(--accent)", flexShrink: 0,
                }}></span>
                <span style={{
                  fontFamily: "var(--mono)", fontSize: 9, letterSpacing: "0.16em",
                  color: "var(--ink-3)", textTransform: "uppercase",
                }}>有料プラン予定あり · paid tier coming</span>
              </div>
            </form>
          </Reveal>
        </div>
      </div>

      <style>{`
        @media (max-width: 820px) {
          .signup-grid { grid-template-columns: 1fr !important; gap: 40px !important; }
        }
      `}</style>
    </section>
  );
}

/* ────────────────────────────────────────────────────────────────
   FOOTER
   ──────────────────────────────────────────────────────────────── */
function Footer() {
  return (
    <footer style={{ background: "var(--bg)", borderTop: "1px solid var(--line-2)", padding: "72px 0 48px" }}>
      <div className="wrap">
        <div style={{ display: "grid", gridTemplateColumns: "1.4fr 1fr 1fr 1fr", gap: 48, marginBottom: 64 }} className="foot-grid">
          <div>
            <div className="logo" style={{ marginBottom: 14 }}>
              shiwake <small>シワケ</small>
            </div>
            <p style={{ fontSize: 13, color: "var(--ink-2)", lineHeight: 1.85, maxWidth: 320 }}>
              話すだけで、AI が食事・体重・メモに自動仕訳する iPhone 日記。減量中の毎日を、もう少しだけ静かにします。
            </p>
          </div>
          <FooterCol title="Product" items={["機能", "1日の使い方", "AI の仕組み", "グラフ"]} />
          <FooterCol title="Company" items={["会社概要", "お問い合わせ", "プレスキット"]} />
          <FooterCol title="Legal" items={["プライバシーポリシー", "利用規約", "特定商取引法"]} />
        </div>
        <hr className="rule-2" />
        <div style={{ display: "flex", justifyContent: "space-between", paddingTop: 28, flexWrap: "wrap", gap: 12 }}>
          <span className="mono-sm">© 2026 shiwake inc. — All rights reserved.</span>
          <span className="mono-sm">Made quietly in Tokyo &middot; 静かに東京で</span>
        </div>
      </div>

      <style>{`
        @media (max-width: 820px) {
          .foot-grid { grid-template-columns: 1fr 1fr !important; }
        }
      `}</style>
    </footer>
  );
}
function FooterCol({ title, items }) {
  return (
    <div>
      <div className="mono-sm" style={{ marginBottom: 16 }}>{title}</div>
      <ul style={{ listStyle: "none", display: "grid", gap: 10 }}>
        {items.map((it) => (
          <li key={it}>
            <a href="#" style={{ fontSize: 13, color: "var(--ink-2)", transition: "color .2s" }}
               onMouseEnter={(e) => e.currentTarget.style.color = "var(--ink)"}
               onMouseLeave={(e) => e.currentTarget.style.color = "var(--ink-2)"}>{it}</a>
          </li>
        ))}
      </ul>
    </div>
  );
}

/* ────────────────────────────────────────────────────────────────
   HOW IT WORKS — 3 steps with phone mockups
   ──────────────────────────────────────────────────────────────── */
function HowItWorks() {
  const steps = [
    {
      n: "01", en: "Open", jp: "起動",
      title: "アプリを開く。",
      body: "ホーム画面、ロック画面ウィジェット、ショートカット。最短ルートで、カメラ画面が立ち上がる。",
      screen: <CameraScreen />,
    },
    {
      n: "02", en: "Speak", jp: "話す",
      title: "長押しで、話す。",
      body: "「ラーメン二郎ヤサイマシマシ、体重 67.8」。一息でかまわない。リアルタイムに文字起こしされる。",
      screen: <RecordingScreen />,
    },
    {
      n: "03", en: "Done", jp: "完了",
      title: "あとは任せる。",
      body: "AI が食事 / 体重 / メモに仕訳。Web 検索でカロリーを補完。タップひとつせず、今日のサマリが完成。",
      screen: <SummaryScreen />,
    },
  ];

  return (
    <section id="how" style={{ background: "var(--bg)" }}>
      <div className="wrap">
        <Reveal>
          <div className="mono" style={{ marginBottom: 18 }}>04 — How it works</div>
        </Reveal>
        <Reveal delay={120}>
          <h2 className="serif" style={{
            fontSize: "clamp(34px, 4vw, 56px)",
            fontWeight: 500,
            lineHeight: 1.18,
            letterSpacing: "-0.015em",
            maxWidth: 780,
            marginBottom: 18,
            textWrap: "pretty",
          }}>
            記録に必要なのは3ステップだけ。
          </h2>
        </Reveal>
        <Reveal delay={200}>
          <p style={{ color: "var(--ink-2)", fontSize: 15, lineHeight: 1.85, maxWidth: 540, marginBottom: 72 }}>
            開く、話す、終わる。シワケで記録に必要なのは、たった 3 つの動作。あとはアプリが裏で全部やります。
          </p>
        </Reveal>

        <div style={{
          display: "grid",
          gridTemplateColumns: "repeat(3, 1fr)",
          gap: 48,
        }} className="how-grid">
          {steps.map((s, i) => (
            <Reveal key={s.n} delay={i * 100}>
              <article style={{ display: "flex", flexDirection: "column", gap: 24 }}>
                <div style={{
                  display: "flex", alignItems: "baseline",
                  borderTop: "1px solid var(--line-2)",
                  paddingTop: 18,
                  gap: 14,
                }}>
                  <span className="serif" style={{
                    fontSize: 40, fontWeight: 500, letterSpacing: "-0.02em",
                    color: "var(--accent)", lineHeight: 1,
                  }}>{s.n}</span>
                  <div style={{ display: "flex", flexDirection: "column", gap: 2 }}>
                    <span className="mono-sm">STEP — {s.en}</span>
                    <span style={{ fontSize: 12, color: "var(--ink-2)" }}>{s.jp}</span>
                  </div>
                </div>
                <div>
                  <h3 className="serif" style={{
                    fontSize: 24, fontWeight: 500, letterSpacing: "-0.01em",
                    lineHeight: 1.35, marginBottom: 12, color: "var(--ink)",
                  }}>{s.title}</h3>
                  <p style={{
                    fontSize: 14, lineHeight: 1.85, color: "var(--ink-2)",
                  }}>{s.body}</p>
                </div>
                <div className="phone-shell" style={{ maxWidth: 280, marginTop: "auto" }}>
                  <div className="phone-notch"></div>
                  <div className="phone-screen">{s.screen}</div>
                </div>
              </article>
            </Reveal>
          ))}
        </div>
      </div>

      <style>{`
        @media (max-width: 900px) {
          .how-grid { grid-template-columns: 1fr !important; gap: 64px !important; }
        }
      `}</style>
    </section>
  );
}

/* ────────────────────────────────────────────────────────────────
   SCREENS — 4-phone editorial gallery
   ──────────────────────────────────────────────────────────────── */
function Screens() {
  const items = [
    {
      n: "01", en: "Capture",
      title: "話す瞬間。",
      caption: "長押しで話すと、文字起こしと波形がリアルタイムに進む。手元を見ずに記録できる。",
      screen: <RecordingScreen />,
      offset: 0,
    },
    {
      n: "02", en: "Summary",
      title: "今日を見渡す。",
      caption: "総カロリー、目標との差、PFC バランス、食事リスト。1 日の輪郭が、開いた瞬間にわかる。",
      screen: <SummaryScreen />,
      offset: 56,
    },
    {
      n: "03", en: "History",
      title: "仕訳の記録。",
      caption: "食事・体重・メモが時系列に並ぶ。フィルターで見たいカテゴリだけを残せる。",
      screen: <HistoryScreen />,
      offset: 24,
    },
    {
      n: "04", en: "Weight",
      title: "ペースを見る。",
      caption: "実測の線と、目標までの理想ペース（青い点線）。順調か、急ぎすぎか、ひと目でわかる。",
      screen: <WeightGraphScreen />,
      offset: 88,
    },
  ];

  return (
    <section id="screens" style={{ background: "var(--bg-2)" }}>
      <div className="wrap">
        <Reveal>
          <div className="mono" style={{ marginBottom: 18 }}>09 — Screens / 画面</div>
        </Reveal>
        <Reveal delay={120}>
          <h2 className="serif" style={{
            fontSize: "clamp(34px, 4vw, 56px)",
            fontWeight: 500,
            lineHeight: 1.18,
            letterSpacing: "-0.015em",
            maxWidth: 780,
            marginBottom: 18,
            textWrap: "pretty",
          }}>
            4 つの画面、<br/>それぞれの仕事。
          </h2>
        </Reveal>
        <Reveal delay={200}>
          <p style={{ color: "var(--ink-2)", fontSize: 15, lineHeight: 1.85, maxWidth: 540, marginBottom: 80 }}>
            機能を増やすのではなく、画面を絞る。シワケに用意したのは、撮る・見渡す・遡る・たどる、の 4 つだけ。
          </p>
        </Reveal>

        <div style={{
          display: "grid",
          gridTemplateColumns: "repeat(2, 1fr)",
          gap: "80px 64px",
        }} className="screens-grid">
          {items.map((it, i) => (
            <Reveal key={it.n} delay={i * 80}>
              <article style={{
                display: "grid",
                gridTemplateColumns: "1fr 220px",
                gap: 28,
                alignItems: "start",
                marginTop: it.offset,
              }} className="screen-card">
                <div style={{ paddingTop: 8 }}>
                  <div style={{
                    display: "flex", alignItems: "baseline", gap: 10,
                    marginBottom: 14,
                  }}>
                    <span className="mono" style={{ color: "var(--accent)" }}>{it.n}</span>
                    <span className="mono-sm">{it.en}</span>
                  </div>
                  <h3 className="serif" style={{
                    fontSize: 26, fontWeight: 500, letterSpacing: "-0.01em",
                    lineHeight: 1.3, marginBottom: 12, color: "var(--ink)",
                  }}>{it.title}</h3>
                  <p style={{
                    fontSize: 13.5, lineHeight: 1.85, color: "var(--ink-2)",
                  }}>{it.caption}</p>
                </div>
                <div className="phone-shell">
                  <div className="phone-notch"></div>
                  <div className="phone-screen">{it.screen}</div>
                </div>
              </article>
            </Reveal>
          ))}
        </div>
      </div>

      <style>{`
        @media (max-width: 1040px) {
          .screens-grid { grid-template-columns: 1fr !important; gap: 64px !important; }
          .screen-card { margin-top: 0 !important; }
        }
        @media (max-width: 560px) {
          .screen-card { grid-template-columns: 1fr !important; }
          .screen-card .phone-shell { max-width: 240px; }
        }
      `}</style>
    </section>
  );
}

/* ────────────────────────────────────────────────────────────────
   02 — THE PAIN
   ──────────────────────────────────────────────────────────────── */
function ThePain() {
  const items = [
    { label: "カロリー記録", per: "1 食", taps: 7, keys: 3, totalDaily: 21 },
    { label: "体重入力", per: "1 回", taps: 15, keys: 0, totalDaily: 15 },
    { label: "運動記録", per: "1 件", taps: 8, keys: 0, totalDaily: 8 },
  ];

  const dailyTaps = 44;
  const dailyKeys = 9;
  const yearlyTaps = dailyTaps * 365;
  const threeYearTaps = yearlyTaps * 3;

  return (
    <section id="pain" style={{ background: "var(--bg-2)" }}>
      <div className="wrap">
        <Reveal>
          <div className="mono" style={{ marginBottom: 18 }}>02 — The pain</div>
        </Reveal>
        <Reveal delay={120}>
          <h2 className="serif" style={{
            fontSize: "clamp(34px, 4.4vw, 60px)",
            fontWeight: 500,
            lineHeight: 1.15,
            letterSpacing: "-0.02em",
            maxWidth: 880,
            marginBottom: 18,
            textWrap: "pretty",
          }}>
            これを、<span style={{ fontStyle: "italic", color: "var(--accent)" }}>毎日 365 日</span>...？
          </h2>
        </Reveal>
        <Reveal delay={200}>
          <p style={{ color: "var(--ink-2)", fontSize: 15, lineHeight: 1.85, maxWidth: 560, marginBottom: 56 }}>
            時間帯を選んで、メニューを探して、量を入れて、保存ボタン。<br/>
            記録にかかる長い動線が、あなたのモチベーションを削っていた。。
          </p>
        </Reveal>

        {/* Tap visualization cards */}
        <Reveal delay={240}>
          <div style={{
            display: "grid",
            gridTemplateColumns: "repeat(3, 1fr)",
            gap: 24,
            marginBottom: 56,
          }} className="pain-grid">
            {items.map((it) => (
              <article key={it.label} style={{
                background: "var(--paper)",
                border: "1px solid var(--line-2)",
                borderRadius: 12,
                padding: "28px 26px",
                display: "flex", flexDirection: "column", gap: 18,
              }}>
                <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline" }}>
                  <div>
                    <div className="serif" style={{ fontSize: 20, fontWeight: 500, letterSpacing: "-0.01em" }}>
                      {it.label}
                    </div>
                    <div className="mono-sm" style={{ marginTop: 4 }}>per {it.per}</div>
                  </div>
                  <div style={{ display: "flex", alignItems: "baseline", gap: 3 }}>
                    <span className="serif" style={{
                      fontSize: 32, fontWeight: 500, color: "var(--accent)", lineHeight: 1, letterSpacing: "-0.02em",
                    }}>{it.totalDaily}</span>
                    <span className="mono-sm" style={{ fontSize: 9 }}>/日</span>
                  </div>
                </div>

                {/* dots */}
                <div style={{
                  display: "flex", flexWrap: "wrap", gap: 6, alignItems: "center",
                  padding: "16px 0",
                  borderTop: "1px dashed var(--line-2)",
                  borderBottom: "1px dashed var(--line-2)",
                }}>
                  {Array.from({ length: it.taps }).map((_, i) => (
                    <span key={`t${i}`} style={{
                      width: 10, height: 10, borderRadius: "50%",
                      background: "var(--ink)", display: "inline-block",
                    }}></span>
                  ))}
                  {it.keys > 0 && (
                    <React.Fragment>
                      <span className="mono-sm" style={{ margin: "0 6px", color: "var(--ink-3)" }}>＋</span>
                      {Array.from({ length: it.keys }).map((_, i) => (
                        <span key={`k${i}`} style={{
                          width: 14, height: 10, borderRadius: 2,
                          background: "var(--accent)", display: "inline-block",
                        }}></span>
                      ))}
                    </React.Fragment>
                  )}
                </div>

                <div style={{ fontSize: 12, color: "var(--ink-2)", lineHeight: 1.6 }}>
                  {it.keys > 0 ? (
                    <React.Fragment>
                      <span style={{ color: "var(--ink-3)" }}>(&nbsp;</span>
                      <span style={{ color: "var(--ink)", fontWeight: 500 }}>{it.taps} タップ</span>
                      <span style={{ color: "var(--ink-3)" }}>　＋　</span>
                      <span style={{ color: "var(--accent)", fontWeight: 500 }}>キー入力</span>
                      <span style={{ color: "var(--ink-3)" }}>&nbsp;) × 3</span>
                    </React.Fragment>
                  ) : (
                    <span style={{ color: "var(--ink)", fontWeight: 500 }}>{it.taps} タップ</span>
                  )}
                </div>
              </article>
            ))}
          </div>
        </Reveal>

        {/* Accumulation */}
        <Reveal delay={280}>
          <div style={{
            background: "var(--paper)",
            border: "1px solid var(--line)",
            borderRadius: 12,
            padding: "36px 40px",
            marginBottom: 48,
          }}>
            <div className="mono-sm" style={{ marginBottom: 18, color: "var(--ink-3)" }}>ACCUMULATED · 積み上がる負担</div>
            <div style={{
              display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 24,
            }} className="pain-acc-grid">
              <PainStat n={dailyTaps} unit="タップ/日" sub={`＋ キー入力 ${dailyKeys}`} />
              <PainStat n={yearlyTaps.toLocaleString()} unit="タップ/年" sub="365 日続けたら" emphasize />
              <PainStat n={threeYearTaps.toLocaleString()} unit="タップ/3年" sub="その先まで続けたら" />
            </div>
          </div>
        </Reveal>

        {/* Contrast */}
        <Reveal delay={320}>
          <div style={{
            display: "flex", alignItems: "center", justifyContent: "center",
            gap: 22, padding: "40px 32px",
            background: "rgba(196,106,78,0.06)",
            borderLeft: "2px solid var(--accent)",
            borderRadius: 6,
          }} className="pain-contrast">
            <span className="mono-sm" style={{ color: "var(--accent)" }}>shiwake なら</span>
            <span style={{ width: 1, height: 24, background: "var(--line)" }}></span>
            <span className="serif" style={{
              fontSize: 24, fontWeight: 500, color: "var(--ink)", letterSpacing: "-0.01em",
              fontStyle: "italic",
            }}>
              話すだけ。
            </span>
            <span style={{ width: 1, height: 24, background: "var(--line)" }}></span>
            <span style={{ display: "inline-flex", gap: 6, alignItems: "center" }}>
              <span style={{ width: 10, height: 10, borderRadius: "50%", background: "var(--accent)" }}></span>
              <span style={{ width: 10, height: 10, borderRadius: "50%", border: "1px solid var(--ink-3)" }}></span>
              <span style={{ width: 10, height: 10, borderRadius: "50%", border: "1px solid var(--ink-3)" }}></span>
            </span>
            <span className="mono-sm" style={{ color: "var(--ink-3)" }}>起動 → 話す → 終わり</span>
          </div>
        </Reveal>
      </div>

      <style>{`
        @media (max-width: 900px) {
          .pain-grid { grid-template-columns: 1fr !important; }
          .pain-acc-grid { grid-template-columns: 1fr !important; gap: 28px !important; }
          .pain-contrast { flex-direction: column !important; gap: 16px !important; text-align: center; }
        }
      `}</style>
    </section>
  );
}

function PainStat({ n, unit, sub, emphasize }) {
  return (
    <div>
      <div style={{ display: "flex", alignItems: "baseline", gap: 6 }}>
        <span className="serif" style={{
          fontSize: emphasize ? 56 : 40,
          fontWeight: 500, lineHeight: 1, letterSpacing: "-0.025em",
          color: emphasize ? "var(--accent)" : "var(--ink)",
        }}>{n}</span>
        <span className="mono-sm" style={{ fontSize: 10 }}>{unit}</span>
      </div>
      <div className="mono-sm" style={{ marginTop: 8, color: "var(--ink-3)" }}>{sub}</div>
    </div>
  );
}

/* ────────────────────────────────────────────────────────────────
   03 — NO KEYBOARD
   ──────────────────────────────────────────────────────────────── */
function NoKeyboard() {
  const modes = [
    {
      tag: "VOICE",
      sub: "食べながら",
      mark: "●",
      score: "BEST",
      title: "話すだけで、終わる。",
      lines: [
        "「やよい軒の唐揚げ定食、ご飯大盛り」",
        "「二郎の小ヤサイマシマシニンニク」",
        "「ドレッシングは大さじ 1 でかけた」",
      ],
      verdict: "確認も、訂正も、声で完結。",
      tier: "best",
    },
    {
      tag: "PHOTO",
      sub: "撮影前提",
      mark: "◐",
      score: "OK",
      title: "撮って、保存。",
      lines: [
        "食材や量が、一目でわかる。",
        "ただし、撮るために手は止まる。",
        "食べ始めたら、もう撮れない。",
      ],
      verdict: "認識はそこそこ。慣れれば許容圏内。",
      tier: "mid",
    },
    {
      tag: "KEYBOARD",
      sub: "戻ってくる地獄",
      mark: "✕",
      score: "WORST",
      title: "結局、これに戻る。",
      lines: [
        "メニュー名を、文字で打つ。",
        "数字を、文字で打つ。",
        "「保存」ボタンを、押す。",
      ],
      verdict: "1 食ごとに、これ。続くわけがない。",
      tier: "worst",
    },
  ];

  const tierStyle = {
    best: {
      bg: "var(--paper)",
      border: "1px solid var(--accent)",
      titleColor: "var(--ink)",
      markColor: "var(--accent)",
      scoreColor: "var(--accent)",
      verdictColor: "var(--ink)",
      verdictBg: "rgba(196,106,78,0.08)",
      borderLeft: "2px solid var(--accent)",
    },
    mid: {
      bg: "var(--paper)",
      border: "1px solid var(--line-2)",
      titleColor: "var(--ink-2)",
      markColor: "var(--ink-2)",
      scoreColor: "var(--ink-2)",
      verdictColor: "var(--ink-2)",
      verdictBg: "rgba(0,0,0,0.03)",
      borderLeft: "2px solid var(--line)",
    },
    worst: {
      bg: "#f0ece4",
      border: "1px dashed var(--ink-3)",
      titleColor: "var(--ink-3)",
      markColor: "var(--ink-3)",
      scoreColor: "var(--ink-3)",
      verdictColor: "var(--ink-2)",
      verdictBg: "rgba(0,0,0,0.04)",
      borderLeft: "2px solid var(--ink-3)",
      textDecoration: "line-through",
    },
  };

  return (
    <section id="no-keyboard" style={{ background: "var(--bg)" }}>
      <div className="wrap">
        <Reveal>
          <div className="mono" style={{ marginBottom: 18 }}>03 — Why no keyboard</div>
        </Reveal>
        <Reveal delay={120}>
          <h2 className="serif" style={{
            fontSize: "clamp(34px, 4.4vw, 60px)",
            fontWeight: 500,
            lineHeight: 1.18,
            letterSpacing: "-0.02em",
            maxWidth: 920,
            marginBottom: 18,
            textWrap: "pretty",
          }}>
            キーボードを使った記録、<br/>
            <span style={{ fontStyle: "italic", color: "var(--accent)" }}>
              やめませんか？
            </span>
          </h2>
        </Reveal>
        <Reveal delay={200}>
          <p style={{ color: "var(--ink-2)", fontSize: 15, lineHeight: 1.85, maxWidth: 600, marginBottom: 56 }}>
            ストレスの少ない記録方法で。<br/>
            音声でも、写真でも、ちゃんと作れば「ネイティブ」に終わる。続かない本当の理由は、結局どこかでキーボードに戻ってくることです。
          </p>
        </Reveal>

        {/* 3-column mode comparison */}
        <div style={{
          display: "grid",
          gridTemplateColumns: "repeat(3, 1fr)",
          gap: 24,
          marginBottom: 48,
        }} className="nk-grid">
          {modes.map((m, i) => {
            const s = tierStyle[m.tier];
            return (
              <Reveal key={m.tag} delay={i * 120}>
                <article style={{
                  background: s.bg,
                  border: s.border,
                  borderRadius: 14,
                  padding: "32px 28px 28px",
                  height: "100%",
                  display: "flex", flexDirection: "column", gap: 18,
                  position: "relative",
                }}>
                  {m.tier === "best" && (
                    <span style={{
                      position: "absolute", top: -10, right: 18,
                      background: "var(--accent)", color: "var(--bg)",
                      padding: "3px 10px", borderRadius: 99,
                      fontFamily: "var(--mono)", fontSize: 9, letterSpacing: "0.16em",
                      textTransform: "uppercase",
                    }}>★ shiwake</span>
                  )}
                  {m.tier === "worst" && (
                    <span style={{
                      position: "absolute", top: -10, right: 18,
                      background: "var(--bg)", color: "var(--ink-3)",
                      padding: "3px 10px", borderRadius: 99,
                      border: "1px dashed var(--ink-3)",
                      fontFamily: "var(--mono)", fontSize: 9, letterSpacing: "0.16em",
                      textTransform: "uppercase",
                    }}>✕ 避ける</span>
                  )}

                  {/* Header: mark + tag + score */}
                  <div style={{ display: "flex", alignItems: "flex-start", justifyContent: "space-between", gap: 12 }}>
                    <div>
                      <div className="mono-sm" style={{ color: s.markColor, marginBottom: 4 }}>
                        {m.tag} · {m.sub}
                      </div>
                      <div style={{
                        fontSize: 44, fontWeight: 500, lineHeight: 1,
                        color: s.markColor, letterSpacing: "-0.02em",
                        fontFamily: "var(--serif)",
                      }}>{m.mark}</div>
                    </div>
                    <span style={{
                      fontFamily: "var(--mono)", fontSize: 9, letterSpacing: "0.18em",
                      color: s.scoreColor, textTransform: "uppercase",
                      border: "1px solid " + s.scoreColor,
                      padding: "3px 8px", borderRadius: 99,
                      flexShrink: 0,
                    }}>{m.score}</span>
                  </div>

                  {/* Title */}
                  <h3 className="serif" style={{
                    fontSize: 22, fontWeight: 500, letterSpacing: "-0.01em",
                    lineHeight: 1.35,
                    color: s.titleColor,
                    textDecoration: s.textDecoration || "none",
                  }}>{m.title}</h3>

                  {/* Lines */}
                  <ul style={{ listStyle: "none", display: "flex", flexDirection: "column", gap: 12, flex: 1 }}>
                    {m.lines.map((t) => (
                      <li key={t} style={{
                        display: "flex", alignItems: "flex-start", gap: 10,
                        fontSize: 13, lineHeight: 1.7,
                        color: s.titleColor,
                      }}>
                        <span style={{
                          width: 4, height: 4, borderRadius: "50%",
                          background: s.markColor,
                          flexShrink: 0, marginTop: 9,
                        }}></span>
                        <span style={m.tier === "best" ? { fontFamily: "var(--serif)", fontStyle: "italic" } : {}}>
                          {t}
                        </span>
                      </li>
                    ))}
                  </ul>

                  {/* Verdict */}
                  <div style={{
                    background: s.verdictBg,
                    borderLeft: s.borderLeft,
                    padding: "12px 14px",
                    borderRadius: 4,
                    fontSize: 12, lineHeight: 1.65,
                    color: s.verdictColor,
                  }}>{m.verdict}</div>
                </article>
              </Reveal>
            );
          })}
        </div>

        {/* Bottom note */}
        <Reveal delay={240}>
          <p style={{
            marginTop: 20, fontSize: 13, color: "var(--ink-3)", lineHeight: 1.85, textAlign: "center",
            fontStyle: "italic",
            maxWidth: 720, marginLeft: "auto", marginRight: "auto",
          }}>
            ——「音声入力できます」「写真で自動」と書いてあっても、<br/>
            結局どこかでキーボードに戻ってくる。その瞬間が、続かない理由です。
          </p>
        </Reveal>
      </div>

      <style>{`
        @media (max-width: 900px) {
          .nk-grid { grid-template-columns: 1fr !important; }
        }
      `}</style>
    </section>
  );
}

Object.assign(window, { Nav, Hero, Features, HowItWorks, Day, AI, Graph, Screens, Signup, Footer, ThePain, NoKeyboard });
