// All detail pages except home
const { useEffect: uE, useState: uS } = React;

// ---- Page wrapper with header hero ----
function PageHero({ kicker, jp, en, sub, bg = "var(--ink-2)", accent = "var(--gold-3)", ink = "var(--moon)" }) {
  return (
    <section className="page-hero" style={{ background: bg, color: ink }}>
      <div className="w-col ph-inner">
        <div className="ph-kicker" style={{ color: accent }}>
          <span style={{ background: accent }} /> {kicker}
        </div>
        <h1 className="ph-title">
          {jp}
          <span className="en-sub" style={{ color: accent }}>{en}</span>
        </h1>
        {sub && <p className="ph-sub">{sub}</p>}
      </div>
      <style>{`
        .page-hero { padding: 200px var(--pad) 120px; position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
        .ph-kicker { display: inline-flex; align-items: center; gap: 14px; font-family: var(--serif-en); font-size: 11px; letter-spacing: 0.4em; text-transform: uppercase; }
        .ph-kicker span { width: 40px; height: 1px; display: inline-block; }
        .ph-title { font-size: clamp(48px, 6vw, 92px); line-height: 1.24; letter-spacing: 0.12em; margin-top: 28px; font-weight: 300; }
        .ph-sub { font-family: var(--serif-en); font-size: 16px; letter-spacing: 0.18em; font-style: italic; margin-top: 32px; opacity: 0.8; max-width: 56ch; }
      `}</style>
    </section>
  );
}

// ============================================================
// VILLAS index
// ============================================================
function VillasPage({ onNav }) {
  return (
    <main className="page-enter">
      <PageHero
        kicker="Villas · 全七棟の離れ"
        jp={<>七棟、七つの、<br/>静けさ。</>}
        en="Seven villas, seven silences."
        sub="すべての棟に、専用の門、専用の石段、そして専用の露天風呂。他の客と、ただの一度も顔を合わせずに終えることのできる滞在を、月彩はご提供します。"
      />
      <section style={{ padding: "120px 0 160px", background: "var(--moon-3)" }}>
        <div className="w-col" style={{ display: "grid", gap: 80 }}>
          {VILLAS.map((v, i) => (
            <Reveal key={v.id}>
              <a className="v-row" href={`#/villa/${v.id}`}
                 onClick={(e) => { e.preventDefault(); onNav(`villa:${v.id}`); }}
                 style={{ flexDirection: i % 2 === 0 ? "row" : "row-reverse" }}>
                <div className="v-row-media" style={{ background: v.hue.bg }}>
                  <VillaSilhouette villa={v} />
                </div>
                <div className="v-row-body">
                  <div className="v-row-top">
                    <span className="num">{v.no} / 07</span>
                    <span style={{ color: v.hue.accent }}>{v.theme}</span>
                  </div>
                  <div className="v-row-jp">{v.jp}</div>
                  <div className="v-row-yomi en">{v.yomi}</div>
                  <div className="v-row-sub">{v.subtitle}</div>
                  <p className="prose" style={{ marginTop: 24, maxWidth: "44ch" }}>{v.tagline}</p>
                  <div className="v-row-meta">
                    <div><span className="m-lb">面積</span><span>{v.size}</span></div>
                    <div><span className="m-lb">定員</span><span>{v.guests}</span></div>
                    <div><span className="m-lb">一泊二食</span><span>{v.price}</span></div>
                  </div>
                  <div className="v-row-cta">View villa →</div>
                </div>
              </a>
            </Reveal>
          ))}
        </div>
      </section>
      <style>{`
        .v-row { display: flex; align-items: stretch; gap: 80px; transition: all .5s; }
        .v-row-media { flex: 1.2; aspect-ratio: 4/3; position: relative; overflow: hidden; transition: transform .6s; }
        .v-row:hover .v-row-media { transform: scale(0.985); }
        .v-row-body { flex: 1; display: flex; flex-direction: column; justify-content: center; color: var(--ink); }
        .v-row-top { display: flex; justify-content: space-between; font-family: var(--serif-en); font-size: 11px; letter-spacing: 0.36em; text-transform: uppercase; color: var(--ash); padding-bottom: 20px; border-bottom: 1px solid var(--line); }
        .v-row-jp { font-size: clamp(80px, 9vw, 140px); line-height: 1; letter-spacing: 0.05em; margin-top: 28px; color: var(--ink); }
        .v-row-yomi { font-size: 20px; letter-spacing: 0.4em; color: var(--gold-2); margin-top: 12px; }
        .v-row-sub { font-size: 16px; letter-spacing: 0.16em; margin-top: 16px; color: var(--ink-3); }
        .v-row-meta { display: flex; gap: 40px; margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); }
        .v-row-meta > div { display: flex; flex-direction: column; gap: 4px; }
        .m-lb { font-family: var(--serif-en); font-size: 10px; letter-spacing: 0.32em; color: var(--ash); text-transform: uppercase; }
        .v-row-cta { margin-top: 36px; font-family: var(--serif-en); font-size: 12px; letter-spacing: 0.4em; color: var(--gold); text-transform: uppercase; }
        @media (max-width: 900px) { .v-row { flex-direction: column !important; gap: 40px; } }
      `}</style>
    </main>
  );
}

// ============================================================
// VILLA DETAIL
// ============================================================
function VillaDetail({ id, onNav }) {
  const v = VILLAS.find((x) => x.id === id) || VILLAS[0];
  const idx = VILLAS.indexOf(v);
  const prev = VILLAS[(idx + VILLAS.length - 1) % VILLAS.length];
  const next = VILLAS[(idx + 1) % VILLAS.length];

  return (
    <main className="page-enter">
      <section className="vd-hero" style={{ background: v.hue.bg, color: v.hue.ink }}>
        <div className="w-col vd-hero-inner">
          <div className="vd-hero-left">
            <div className="num" style={{ color: v.hue.accent }}>{v.no} / 07 · {v.theme}</div>
            <div className="vd-jp">{v.jp}</div>
            <div className="vd-yomi en">{v.yomi}</div>
            <div className="vd-sub">{v.subtitle}</div>
            <p className="vd-tag">{v.tagline}</p>
          </div>
          <div className="vd-hero-right">
            <VillaSilhouette villa={v} />
          </div>
        </div>
      </section>

      <section className="vd-body" style={{ padding: "140px 0" }}>
        <div className="w-col" style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 120, alignItems: "start" }}>
          <div>
            <span className="kicker">About · 棟について</span>
            <h2 className="section-title" style={{ marginTop: 20, fontSize: "clamp(28px, 3vw, 42px)" }}>
              {v.tagline}
            </h2>
            <p className="prose" style={{ marginTop: 32 }}>{v.desc}</p>
            <div className="vd-meta">
              <div><div className="m-lb">面積</div><div>{v.size}</div></div>
              <div><div className="m-lb">定員</div><div>{v.guests}</div></div>
              <div><div className="m-lb">一泊二食</div><div>{v.price}</div></div>
              <div><div className="m-lb">お風呂</div><div>専用露天 + 内湯</div></div>
            </div>
          </div>
          <div>
            <span className="kicker">Features · しつらえ</span>
            <ul className="vd-feats">
              {v.features.map((f, i) => (
                <li key={i}><span className="num">0{i + 1}</span>{f}</li>
              ))}
            </ul>
            {/* Floor plan */}
            <div className="vd-plan">
              <div className="vd-plan-title en-up" style={{ color: "var(--ash)" }}>Floor plan · 間取り</div>
              <FloorPlan villa={v} />
            </div>
          </div>
        </div>
      </section>

      {/* Room gallery */}
      <section style={{ padding: "40px 0 140px", background: "var(--moon-3)" }}>
        <div className="w-col">
          <div className="vd-gal">
            <div className="vd-gal-main" style={{ background: v.hue.bg }}>
              <RoomSketch villa={v} kind="onsen" />
              <span className="vd-gal-cap">専用露天風呂 · Private onsen</span>
            </div>
            <div className="vd-gal-a" style={{ background: v.hue.bg }}>
              <RoomSketch villa={v} kind="room" />
              <span className="vd-gal-cap">主室 · Main room</span>
            </div>
            <div className="vd-gal-b" style={{ background: v.hue.bg }}>
              <RoomSketch villa={v} kind="engawa" />
              <span className="vd-gal-cap">広縁 · Engawa</span>
            </div>
          </div>
        </div>
      </section>

      {/* Adjacent villas nav */}
      <section style={{ background: "var(--ink-2)", color: "var(--moon)", padding: "80px 0" }}>
        <div className="w-col" style={{ display: "grid", gridTemplateColumns: "1fr auto 1fr", gap: 40, alignItems: "center" }}>
          <a className="vd-nav" href={`#/villa/${prev.id}`} onClick={(e) => { e.preventDefault(); onNav(`villa:${prev.id}`); }}>
            <span className="vd-nav-lb">← 前の棟</span>
            <span className="vd-nav-jp">{prev.jp}</span>
            <span className="en">{prev.yomi}</span>
          </a>
          <a className="btn-ghost" style={{ color: "var(--moon)", borderColor: "var(--gold)" }}
             href="#/villas" onClick={(e) => { e.preventDefault(); onNav("villas"); }}>
            全棟を見る
          </a>
          <a className="vd-nav" style={{ textAlign: "right" }} href={`#/villa/${next.id}`}
             onClick={(e) => { e.preventDefault(); onNav(`villa:${next.id}`); }}>
            <span className="vd-nav-lb">次の棟 →</span>
            <span className="vd-nav-jp">{next.jp}</span>
            <span className="en">{next.yomi}</span>
          </a>
        </div>
      </section>

      <style>{`
        .vd-hero { padding: 180px var(--pad) 120px; }
        .vd-hero-inner { display: grid; grid-template-columns: 1fr 1.1fr; gap: 80px; align-items: center; }
        .vd-jp { font-size: clamp(140px, 18vw, 260px); line-height: 1; letter-spacing: 0.04em; margin-top: 32px; }
        .vd-yomi { font-size: clamp(28px, 3vw, 44px); letter-spacing: 0.4em; opacity: 0.55; margin-top: 20px; font-style: italic; }
        .vd-sub { font-size: 18px; letter-spacing: 0.2em; margin-top: 30px; }
        .vd-tag { font-size: clamp(22px, 2.4vw, 32px); line-height: 1.7; letter-spacing: 0.14em; margin-top: 40px; max-width: 18ch; }
        .vd-hero-right { aspect-ratio: 4/3; overflow: hidden; }
        .vd-meta { margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
        .vd-meta > div > div:first-child { font-family: var(--serif-en); font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--ash); margin-bottom: 6px; }
        .vd-meta > div > div:last-child { font-size: 15px; letter-spacing: 0.08em; }
        .vd-feats { list-style: none; padding: 0; margin: 32px 0 0; }
        .vd-feats li { padding: 18px 0; border-bottom: 1px solid var(--line); font-size: 16px; letter-spacing: 0.08em; display: flex; gap: 20px; }
        .vd-plan { margin-top: 64px; padding-top: 28px; border-top: 1px solid var(--line); }
        .vd-plan-title { font-size: 10px; margin-bottom: 20px; }
        .vd-gal { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 16px; aspect-ratio: 2/1.1; }
        .vd-gal-main { grid-row: 1 / 3; position: relative; }
        .vd-gal-a, .vd-gal-b { position: relative; }
        .vd-gal-cap { position: absolute; bottom: 20px; left: 20px; font-family: var(--serif-en); font-size: 10px; letter-spacing: 0.4em; text-transform: uppercase; color: var(--ink-3); opacity: 0.75; }
        .vd-nav { display: flex; flex-direction: column; gap: 6px; opacity: 0.8; transition: opacity .4s; }
        .vd-nav:hover { opacity: 1; }
        .vd-nav-lb { font-family: var(--serif-en); font-size: 11px; letter-spacing: 0.36em; text-transform: uppercase; color: var(--gold-3); }
        .vd-nav-jp { font-size: 34px; letter-spacing: 0.2em; }
        .vd-nav .en { font-size: 13px; letter-spacing: 0.3em; opacity: 0.6; }
        @media (max-width: 900px) { .vd-hero-inner, .vd-body > div, .vd-gal { grid-template-columns: 1fr !important; } .vd-gal { aspect-ratio: auto; } }
      `}</style>
    </main>
  );
}

function FloorPlan({ villa }) {
  const c = villa.hue.ink; const a = villa.hue.accent;
  return (
    <svg viewBox="0 0 400 280" width="100%" style={{ maxWidth: 420 }}>
      <rect x="1" y="1" width="398" height="278" fill="none" stroke={c} strokeWidth="1" opacity="0.2" />
      <rect x="20" y="20" width="240" height="140" fill="none" stroke={c} strokeWidth="1.5" />
      <line x1="140" y1="20" x2="140" y2="160" stroke={c} strokeWidth="0.8" opacity="0.5" />
      <line x1="140" y1="80" x2="260" y2="80" stroke={c} strokeWidth="0.8" opacity="0.5" />
      <text x="80" y="55" fill={c} fontFamily="Shippori Mincho, serif" fontSize="12" letterSpacing="4" textAnchor="middle">主室</text>
      <text x="80" y="130" fill={c} fontFamily="Shippori Mincho, serif" fontSize="12" letterSpacing="4" textAnchor="middle">寝室</text>
      <text x="200" y="55" fill={c} fontFamily="Shippori Mincho, serif" fontSize="11" letterSpacing="3" textAnchor="middle">茶室</text>
      <text x="200" y="130" fill={c} fontFamily="Shippori Mincho, serif" fontSize="11" letterSpacing="3" textAnchor="middle">内湯</text>
      {/* engawa */}
      <rect x="20" y="160" width="240" height="20" fill={c} opacity="0.1" />
      <text x="140" y="175" fill={c} fontFamily="Shippori Mincho, serif" fontSize="10" letterSpacing="3" textAnchor="middle">広縁</text>
      {/* onsen */}
      <rect x="280" y="60" width="100" height="100" fill="none" stroke={a} strokeWidth="1.5" />
      <ellipse cx="330" cy="110" rx="36" ry="28" fill={a} opacity="0.3" />
      <ellipse cx="330" cy="110" rx="30" ry="22" fill={a} opacity="0.5" />
      <text x="330" y="113" fill={c} fontFamily="Shippori Mincho, serif" fontSize="10" letterSpacing="3" textAnchor="middle">露天</text>
      {/* garden */}
      <path d="M20 200 Q 100 190 200 210 Q 300 230 380 200" stroke={c} strokeWidth="0.6" fill="none" opacity="0.4" />
      <text x="200" y="230" fill={c} fontFamily="Shippori Mincho, serif" fontSize="10" letterSpacing="4" textAnchor="middle" opacity="0.6">専用庭</text>
      <g fill={c} opacity="0.3" fontFamily="Cormorant Garamond, serif" fontSize="9" letterSpacing="2">
        <text x="20" y="270">N</text>
        <text x="370" y="270">{villa.size}</text>
      </g>
    </svg>
  );
}

function RoomSketch({ villa, kind }) {
  const c = villa.hue.ink; const a = villa.hue.accent; const bg = villa.hue.bg;
  if (kind === "onsen") return (
    <svg width="100%" height="100%" viewBox="0 0 800 700" preserveAspectRatio="xMidYMid slice">
      <rect width="800" height="700" fill={bg} />
      {/* Sky */}
      <rect x="0" y="0" width="800" height="350" fill={c} opacity="0.08" />
      {/* Garden greenery */}
      <g fill={a} opacity="0.4">
        <circle cx="60" cy="280" r="80" />
        <circle cx="750" cy="250" r="100" />
      </g>
      {/* Stone rim */}
      <ellipse cx="400" cy="460" rx="280" ry="80" fill={c} opacity="0.75" />
      <ellipse cx="400" cy="450" rx="260" ry="66" fill={c} opacity="0.85" />
      {/* Water */}
      <ellipse cx="400" cy="445" rx="230" ry="54" fill={c} opacity="0.9" />
      <ellipse cx="400" cy="442" rx="200" ry="42" fill={c} />
      {/* Ripples */}
      <g stroke={a} strokeWidth="0.8" fill="none" opacity="0.4">
        <ellipse cx="400" cy="442" rx="100" ry="18" />
        <ellipse cx="400" cy="442" rx="140" ry="26" />
      </g>
      {/* Reflected moon */}
      <ellipse cx="380" cy="432" rx="30" ry="5" fill={villa.id === "tsuki" ? "#F1EBD8" : a} opacity="0.6" />
      {/* Steam */}
      <g fill={bg} opacity="0.5">
        <circle cx="340" cy="390" r="16" />
        <circle cx="420" cy="370" r="20" />
        <circle cx="470" cy="400" r="14" />
      </g>
      {/* Bamboo water spout */}
      <rect x="220" y="340" width="8" height="80" fill={c} opacity="0.7" />
      <rect x="210" y="410" width="40" height="8" fill={c} opacity="0.8" />
    </svg>
  );
  if (kind === "room") return (
    <svg width="100%" height="100%" viewBox="0 0 800 700" preserveAspectRatio="xMidYMid slice">
      <rect width="800" height="700" fill={bg} />
      {/* Tatami */}
      <rect x="100" y="460" width="600" height="220" fill={c} opacity="0.1" />
      <g stroke={c} strokeWidth="0.5" opacity="0.3">
        <line x1="200" y1="460" x2="200" y2="680" />
        <line x1="300" y1="460" x2="300" y2="680" />
        <line x1="400" y1="460" x2="400" y2="680" />
        <line x1="500" y1="460" x2="500" y2="680" />
        <line x1="600" y1="460" x2="600" y2="680" />
        <line x1="100" y1="570" x2="700" y2="570" />
      </g>
      {/* Shoji back wall */}
      <rect x="100" y="160" width="600" height="300" fill={bg} stroke={c} strokeWidth="1" />
      <g stroke={c} strokeWidth="0.8" opacity="0.5">
        {[1,2,3,4,5].map(i => <line key={i} x1={100+i*100} y1="160" x2={100+i*100} y2="460" />)}
        {[1,2,3,4].map(i => <line key={i} x1="100" y1={160+i*60} x2="700" y2={160+i*60} />)}
      </g>
      {/* Tokonoma alcove */}
      <rect x="560" y="180" width="120" height="260" fill={c} opacity="0.15" />
      <line x1="620" y1="200" x2="620" y2="420" stroke={c} strokeWidth="0.8" opacity="0.6" />
      {/* hanging scroll */}
      <rect x="600" y="210" width="40" height="120" fill={bg} stroke={c} strokeWidth="0.5" />
      <text x="620" y="260" fontFamily="Shippori Mincho, serif" fontSize="18" fill={c} opacity="0.7" textAnchor="middle">月</text>
      <text x="620" y="285" fontFamily="Shippori Mincho, serif" fontSize="18" fill={c} opacity="0.7" textAnchor="middle">彩</text>
      {/* Ikebana */}
      <ellipse cx="620" cy="400" rx="16" ry="6" fill={c} opacity="0.7" />
      <path d="M620 400 Q 610 360 618 320" stroke={c} strokeWidth="1.2" fill="none" />
      <circle cx="618" cy="320" r="6" fill={a} />
      {/* Low table */}
      <rect x="280" y="540" width="240" height="8" fill={c} opacity="0.7" />
      <rect x="290" y="548" width="6" height="40" fill={c} opacity="0.8" />
      <rect x="504" y="548" width="6" height="40" fill={c} opacity="0.8" />
      {/* Cushions */}
      <ellipse cx="260" cy="600" rx="40" ry="16" fill={c} opacity="0.35" />
      <ellipse cx="540" cy="600" rx="40" ry="16" fill={c} opacity="0.35" />
      {/* Ceiling beam */}
      <rect x="0" y="140" width="800" height="14" fill={c} opacity="0.6" />
    </svg>
  );
  if (kind === "engawa") return (
    <svg width="100%" height="100%" viewBox="0 0 800 700" preserveAspectRatio="xMidYMid slice">
      <rect width="800" height="700" fill={bg} />
      {/* Outer garden */}
      <rect x="0" y="0" width="800" height="340" fill={c} opacity="0.12" />
      <g fill={a} opacity="0.4">
        <circle cx="120" cy="240" r="100" />
        <circle cx="680" cy="200" r="130" />
      </g>
      {/* Wood deck */}
      <rect x="0" y="340" width="800" height="360" fill={c} opacity="0.2" />
      <g stroke={c} strokeWidth="0.4" opacity="0.5">
        {Array.from({length: 8}).map((_, i) => <line key={i} x1="0" y1={380 + i*40} x2="800" y2={380 + i*40} />)}
      </g>
      {/* Pillars */}
      <rect x="120" y="80" width="14" height="260" fill={c} opacity="0.8" />
      <rect x="670" y="80" width="14" height="260" fill={c} opacity="0.8" />
      {/* Eave */}
      <rect x="60" y="80" width="680" height="14" fill={c} opacity="0.85" />
      <path d="M40 94 L120 80 L680 80 L760 94 Z" fill={c} opacity="0.75" />
      {/* Low table w/ tea */}
      <rect x="320" y="500" width="180" height="6" fill={c} opacity="0.8" />
      <ellipse cx="380" cy="490" rx="14" ry="5" fill={c} />
      <ellipse cx="420" cy="490" rx="10" ry="4" fill={a} />
      {/* Cushion */}
      <ellipse cx="200" cy="560" rx="48" ry="18" fill={c} opacity="0.45" />
    </svg>
  );
  return null;
}

// ============================================================
// KIHIN 貴賓棟「宙」
// ============================================================
function KihinPage({ onNav }) {
  return (
    <main className="page-enter">
      <section className="kh-hero">
        <div className="kh-hero-bg">
          <SceneMoon />
        </div>
        <div className="w-col kh-inner">
          <div className="kh-kicker">
            <span /> THE GRAND VILLA · 貴賓棟
          </div>
          <h1 className="kh-title">
            宙(そら)<span className="kh-yomi en">Sora</span>
          </h1>
          <p className="kh-tag">ひと棟だけの、離れの中の離れ。</p>
          <p className="kh-desc prose" style={{ color: "var(--moon-2)" }}>
            他の七棟とはまったく別の区画。専用の門、専用の石段、専用の庭、専用の料亭。月彩のすべての贅(ぜい)を、この一棟に集めました。滞在中、二人の料理人と一人の仲居が、この棟のためだけに控えます。
          </p>
        </div>
      </section>

      <section style={{ padding: "140px 0", background: "var(--moon-3)" }}>
        <div className="w-col" style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 120 }}>
          <div>
            <span className="kicker">Overview</span>
            <h2 className="section-title" style={{ fontSize: "clamp(28px, 3.2vw, 44px)", marginTop: 20 }}>
              宙を抱くための、<br/>ただひとつの棟。
            </h2>
            <div className="kh-stats">
              <div><div className="m-lb">面積</div><div>220㎡</div></div>
              <div><div className="m-lb">専用庭</div><div>600㎡</div></div>
              <div><div className="m-lb">定員</div><div>2〜4名</div></div>
              <div><div className="m-lb">一泊二食</div><div>¥480,000〜</div></div>
            </div>
          </div>
          <div>
            <ul className="kh-feats">
              <li><span className="num">01</span>天井を持たない露天風呂 (空をそのまま仰ぐ)</li>
              <li><span className="num">02</span>専属料亭「七曜」(シェフズテーブル)</li>
              <li><span className="num">03</span>茶室「皓月庵」(表千家)</li>
              <li><span className="num">04</span>書院 + 寝室 × 2 + 次の間</li>
              <li><span className="num">05</span>二人の料理人、一人の仲居が滞在中専任</li>
              <li><span className="num">06</span>ヘリポートからの直接アクセス (応相談)</li>
              <li><span className="num">07</span>黒塗り車での箱根湯本駅お迎え</li>
            </ul>
          </div>
        </div>
      </section>

      <section style={{ padding: "0 0 140px", background: "var(--moon-3)" }}>
        <div className="w-col">
          <div className="kh-gal">
            <div className="kh-gal-main img-ph" style={{ background: "#0F1925" }}>
              <SceneOnsen />
              <span className="kh-gal-cap">空露天 · Open-sky onsen</span>
            </div>
            <div className="kh-gal-a" style={{ background: "#E8DFC5" }}>
              <RoomSketch villa={{ hue: { ink: "#1B2A3E", accent: "#B9986A", bg: "#E8DFC5" }, id: "sora" }} kind="room" />
              <span className="kh-gal-cap">主室 · Main hall</span>
            </div>
            <div className="kh-gal-b" style={{ background: "#D8C9AE" }}>
              <TeaRoomSketch />
              <span className="kh-gal-cap">茶室 皓月庵 · Tea room</span>
            </div>
          </div>
        </div>
      </section>

      <CTABand onNav={onNav} />

      <style>{`
        .kh-hero { position: relative; height: 100vh; min-height: 720px; overflow: hidden; background: #0A0F17; color: var(--moon); }
        .kh-hero-bg { position: absolute; inset: 0; opacity: 0.9; }
        .kh-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(10,15,23,0.3), rgba(10,15,23,0.85)); }
        .kh-inner { position: relative; z-index: 2; height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 0 var(--pad); }
        .kh-kicker { font-family: var(--serif-en); font-size: 11px; letter-spacing: 0.44em; text-transform: uppercase; color: var(--gold-3); display: inline-flex; align-items: center; gap: 14px; }
        .kh-kicker span { width: 40px; height: 1px; background: var(--gold-3); display: inline-block; }
        .kh-title { font-size: clamp(120px, 16vw, 240px); line-height: 1; margin: 32px 0 0; letter-spacing: 0.1em; font-weight: 300; }
        .kh-yomi { display: block; font-size: 36px; letter-spacing: 0.4em; margin-top: 24px; color: var(--gold-3); font-style: italic; }
        .kh-tag { font-size: 26px; line-height: 1.7; letter-spacing: 0.18em; color: var(--moon); margin: 60px 0 28px; }
        .kh-desc { max-width: 52ch; }
        .kh-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--line); }
        .kh-stats .m-lb { font-size: 10px; margin-bottom: 6px; }
        .kh-stats > div > div:last-child { font-size: 22px; letter-spacing: 0.1em; }
        .kh-feats { list-style: none; padding: 0; margin: 0; }
        .kh-feats li { padding: 22px 0; border-bottom: 1px solid var(--line); font-size: 16px; letter-spacing: 0.08em; display: flex; gap: 22px; }
        .kh-gal { display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; gap: 16px; aspect-ratio: 2/1.2; }
        .kh-gal-main { grid-row: 1 / 3; position: relative; overflow: hidden; }
        .kh-gal-a, .kh-gal-b { position: relative; overflow: hidden; }
        .kh-gal-cap { position: absolute; bottom: 20px; left: 20px; font-family: var(--serif-en); font-size: 10px; letter-spacing: 0.4em; text-transform: uppercase; color: var(--moon-2); }
      `}</style>
    </main>
  );
}

function TeaRoomSketch() {
  return (
    <svg width="100%" height="100%" viewBox="0 0 800 700" preserveAspectRatio="xMidYMid slice">
      <rect width="800" height="700" fill="#D8C9AE" />
      {/* back shoji */}
      <rect x="120" y="120" width="560" height="380" fill="#F1EBD8" stroke="#1B2A3E" strokeWidth="1" />
      <g stroke="#1B2A3E" strokeWidth="0.6" opacity="0.5">
        {[1,2,3,4].map(i => <line key={i} x1={120+i*112} y1="120" x2={120+i*112} y2="500" />)}
        {[1,2,3].map(i => <line key={i} x1="120" y1={120+i*95} x2="680" y2={120+i*95} />)}
      </g>
      {/* tatami */}
      <rect x="100" y="500" width="600" height="180" fill="#8F7349" opacity="0.35" />
      <g stroke="#1B2A3E" strokeWidth="0.6" opacity="0.4">
        <line x1="250" y1="500" x2="250" y2="680" />
        <line x1="400" y1="500" x2="400" y2="680" />
        <line x1="550" y1="500" x2="550" y2="680" />
        <line x1="100" y1="590" x2="700" y2="590" />
      </g>
      {/* Ro (sunken hearth) */}
      <rect x="340" y="530" width="120" height="120" fill="#1B2A3E" />
      <rect x="360" y="550" width="80" height="80" fill="#14100A" />
      <circle cx="400" cy="590" r="20" fill="#B9986A" opacity="0.6" />
      <circle cx="400" cy="590" r="10" fill="#D4B884" />
      {/* chashaku and chawan — symbolic */}
      <ellipse cx="240" cy="600" rx="30" ry="10" fill="#1B2A3E" opacity="0.7" />
      <ellipse cx="240" cy="596" rx="26" ry="8" fill="#3B2D1C" />
      {/* hanging calligraphy */}
      <rect x="380" y="160" width="40" height="180" fill="#F1EBD8" stroke="#1B2A3E" strokeWidth="0.5" />
      <text x="400" y="220" fontFamily="Shippori Mincho, serif" fontSize="24" fill="#1B2A3E" textAnchor="middle">皓</text>
      <text x="400" y="250" fontFamily="Shippori Mincho, serif" fontSize="24" fill="#1B2A3E" textAnchor="middle">月</text>
      <text x="400" y="280" fontFamily="Shippori Mincho, serif" fontSize="24" fill="#1B2A3E" textAnchor="middle">庵</text>
    </svg>
  );
}

Object.assign(window, { PageHero, VillasPage, VillaDetail, FloorPlan, RoomSketch, KihinPage, TeaRoomSketch });
