const { useState, useEffect, useRef, useMemo } = React;
const I18N = window.I18N;

// ───────────────────────────────────────────────────────────────────────────
// Responsive hook
// ───────────────────────────────────────────────────────────────────────────

function useIsMobile(breakpoint = 760) {
  const [m, setM] = useState(() => typeof window !== "undefined" && window.innerWidth <= breakpoint);
  useEffect(() => {
    const onR = () => setM(window.innerWidth <= breakpoint);
    window.addEventListener("resize", onR);
    return () => window.removeEventListener("resize", onR);
  }, [breakpoint]);
  return m;
}

const TWEAK_DEFAULTS = /*EDITMODE-BEGIN*/{
  "accent": "#1f4ed8",
  "surface": "warm",
  "headerStyle": "split",
  "showGrid": true,
  "density": "comfortable"
} /*EDITMODE-END*/;

// ───────────────────────────────────────────────────────────────────────────
// Surfaces
// ───────────────────────────────────────────────────────────────────────────

const SURFACES = {
  warm: { bg: "#f6f4ef", panel: "#ffffff", ink: "#1a1714", muted: "#6b6660", line: "#e5e0d7", subtle: "#efece5" },
  cool: { bg: "#f1f3f6", panel: "#ffffff", ink: "#14171c", muted: "#5e6573", line: "#dde1e8", subtle: "#e7ebf1" },
  dark: { bg: "#0f1115", panel: "#161922", ink: "#eef0f5", muted: "#8a91a1", line: "#252a36", subtle: "#1c2029" }
};

// ───────────────────────────────────────────────────────────────────────────
// Small atoms
// ───────────────────────────────────────────────────────────────────────────

function Mono({ children, style }) {
  return <span style={{ fontFamily: "'IBM Plex Mono', ui-monospace, monospace", letterSpacing: "0.04em", ...style }}>{children}</span>;
}

function SectionLabel({ index, label, accent }) {
  return (
    <div style={{ display: "flex", alignItems: "baseline", gap: 14, marginBottom: 28 }}>
      <Mono style={{ fontSize: 11, color: accent, fontWeight: 600 }}>§ {index}</Mono>
      <Mono style={{ fontSize: 11, color: "var(--muted)", textTransform: "uppercase" }}>{label}</Mono>
      <div style={{ flex: 1, height: 1, background: "var(--line)" }}></div>
    </div>);

}

// ───────────────────────────────────────────────────────────────────────────
// Language toggle
// ───────────────────────────────────────────────────────────────────────────

function LangToggle({ lang, setLang, accent }) {
  const opts = [
  { v: "ko", label: "KOR" },
  { v: "en", label: "ENG" }];

  return (
    <div role="group" aria-label="Language" style={{
      display: "inline-flex",
      border: `1px solid var(--line)`,
      background: "var(--panel)",
      padding: 2
    }}>
      {opts.map((o) => {
        const active = lang === o.v;
        return (
          <button key={o.v}
          onClick={() => setLang(o.v)}
          aria-pressed={active}
          style={{
            background: active ? "var(--ink)" : "transparent",
            color: active ? "var(--bg)" : "var(--muted)",
            border: "none",
            padding: "6px 10px",
            cursor: "pointer",
            fontFamily: "'IBM Plex Mono', monospace",
            fontSize: 10,
            fontWeight: 600,
            letterSpacing: "0.08em",
            transition: "background 0.15s, color 0.15s"
          }}>
            {o.label}
          </button>);

      })}
    </div>);

}

// ───────────────────────────────────────────────────────────────────────────
// Header
// ───────────────────────────────────────────────────────────────────────────

function TopBar({ accent, onJump, t, lang, setLang }) {
  const isMobile = useIsMobile();
  const [open, setOpen] = useState(false);
  const links = t.nav;
  return (
    <header style={{
      position: "sticky", top: 0, zIndex: 50,
      background: "var(--bg)", borderBottom: "1px solid var(--line)",
      backdropFilter: "blur(6px)"
    }}>
      <div style={{ maxWidth: 1280, margin: "0 auto", padding: isMobile ? "12px 20px" : "14px 40px", display: "flex", alignItems: "center", justifyContent: "space-between", gap: 12 }}>
        <div style={{ display: "flex", alignItems: "center", gap: 12, minWidth: 0 }}>
          <div style={{ lineHeight: 1.1 }}>
            <div style={{ fontSize: 14, fontWeight: 600, color: "var(--ink)" }}>{t.brand}</div>
          </div>
        </div>
        {isMobile ?
        <div style={{ display: "flex", alignItems: "center", gap: 10 }}>
            <LangToggle lang={lang} setLang={setLang} accent={accent} />
            <button
            aria-label={t.menuAria}
            onClick={() => setOpen((v) => !v)}
            style={{
              background: "transparent", border: `1px solid var(--line)`,
              padding: "8px 12px", cursor: "pointer",
              fontFamily: "'IBM Plex Mono', monospace", fontSize: 11,
              color: "var(--ink)", letterSpacing: "0.04em",
              display: "flex", alignItems: "center", gap: 8
            }}>
              <span style={{ display: "inline-flex", flexDirection: "column", gap: 3 }}>
                <span style={{ width: 14, height: 1.5, background: "currentColor" }}></span>
                <span style={{ width: 14, height: 1.5, background: "currentColor" }}></span>
                <span style={{ width: 14, height: 1.5, background: "currentColor" }}></span>
              </span>
              {open ? t.menuClose : t.menuOpen}
            </button>
          </div> :

        <div style={{ display: "flex", alignItems: "center", gap: 28 }}>
            <nav style={{ display: "flex", gap: 28 }}>
              {links.map(([id, label]) =>
            <a key={id} href={`#${id}`} onClick={(e) => {e.preventDefault();onJump(id);}}
            style={{ textDecoration: "none", color: "var(--ink)", fontSize: 13, fontFamily: "'IBM Plex Mono', monospace", letterSpacing: "0.02em" }}>
                  {label}
                </a>
            )}
            </nav>
            <LangToggle lang={lang} setLang={setLang} accent={accent} />
          </div>
        }
      </div>
      {isMobile && open &&
      <nav style={{
        borderTop: "1px solid var(--line)",
        background: "var(--bg)",
        display: "flex", flexDirection: "column"
      }}>
          {links.map(([id, label]) =>
        <a key={id} href={`#${id}`}
        onClick={(e) => {e.preventDefault();onJump(id);setOpen(false);}}
        style={{
          textDecoration: "none", color: "var(--ink)",
          fontSize: 14, fontFamily: "'IBM Plex Mono', monospace",
          letterSpacing: "0.02em",
          padding: "16px 20px",
          borderBottom: "1px solid var(--line)"
        }}>
              {label}
            </a>
        )}
        </nav>
      }
    </header>);

}

// ───────────────────────────────────────────────────────────────────────────
// Hero
// ───────────────────────────────────────────────────────────────────────────

function Hero({ accent, surface, headerStyle, density, t }) {
  const isMobile = useIsMobile();
  return (
    <section style={{
      borderBottom: "1px solid var(--line)",
      padding: isMobile ?
      density === "compact" ? "40px 20px 56px" : "56px 20px 72px" :
      density === "compact" ? "60px 40px 80px" : "96px 40px 120px"
    }}>
      <div style={{
        maxWidth: 1280, margin: "0 auto", display: "grid",
        gridTemplateColumns: isMobile ? "1fr" : headerStyle === "split" ? "1.4fr 1fr" : "1fr",
        gap: isMobile ? 40 : 64,
        alignItems: "end"
      }}>
        <div style={{ minWidth: 0 }}>
          <Mono style={{ fontSize: isMobile ? 10 : 11, color: accent, fontWeight: 600, display: "block", wordBreak: "keep-all", overflowWrap: "anywhere", lineHeight: 1.5 }}>
            {t.heroEyebrow}
          </Mono>
          <h1 style={{
            lineHeight: isMobile ? 1.1 : 1.02,
            margin: isMobile ? "18px 0 0" : "28px 0 0",
            fontWeight: 600, letterSpacing: "-0.025em", color: "var(--ink)",
            fontSize: isMobile ? "clamp(32px, 9.2vw, 44px)" : "70px",
            wordBreak: "keep-all", overflowWrap: "break-word"
          }}>
            {t.heroHeading1}<br />
            <span style={{ color: accent }}>{t.heroHeadingAcc}</span>{t.heroHeading2}<br />
            {t.heroHeading3}
          </h1>
          {t.heroSub &&
          <div style={{ marginTop: isMobile ? 20 : 24, paddingLeft: isMobile ? 12 : 14, borderLeft: `2px solid ${accent}`, maxWidth: 620 }}>
              <div style={{ fontSize: isMobile ? 14 : 17, lineHeight: 1.5, color: "var(--ink)", fontWeight: 500, letterSpacing: "-0.005em", wordBreak: "keep-all", overflowWrap: "break-word" }}>
                {t.heroSub}
              </div>
            </div>
          }
          <p style={{ marginTop: isMobile ? 24 : 32, maxWidth: 580, fontSize: isMobile ? 15 : 17, lineHeight: 1.6, color: "var(--muted)", wordBreak: "keep-all", overflowWrap: "break-word" }}>
            {t.heroBody}
          </p>
          <div style={{ display: "flex", gap: 12, marginTop: 40, flexWrap: "wrap" }}>
            <button onClick={() => document.getElementById("contact")?.scrollIntoView({ behavior: "smooth" })}
            style={{
              background: "var(--ink)", color: "var(--bg)", border: "none",
              padding: "14px 22px", fontSize: 14, fontWeight: 500, cursor: "pointer",
              fontFamily: "inherit", display: "flex", alignItems: "center", gap: 10
            }}>
              {t.ctaPrimary} <span style={{ fontFamily: "'IBM Plex Mono', monospace" }}>→</span>
            </button>
            <button onClick={() => document.getElementById("cases")?.scrollIntoView({ behavior: "smooth" })}
            style={{
              background: "transparent", color: "var(--ink)", border: "1px solid var(--line)",
              padding: "14px 22px", fontSize: 14, fontWeight: 500, cursor: "pointer",
              fontFamily: "inherit"
            }}>
              {t.ctaSecondary}
            </button>
          </div>
        </div>

        {headerStyle === "split" &&
        <div style={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 1, background: "var(--line)", border: "1px solid var(--line)" }}>
            {t.heroStats.map((s, i) =>
          <div key={i} style={{ background: "var(--panel)", padding: isMobile ? 18 : 24 }}>
                <div style={{ fontSize: isMobile ? s.k.length > 3 ? 26 : 36 : s.k.length > 3 ? 36 : 48, fontWeight: 600, color: "var(--ink)", letterSpacing: "-0.02em" }}>{s.k}</div>
                <Mono style={{ fontSize: 10, color: accent, display: "block", marginTop: 4 }}>{s.u.toUpperCase()}</Mono>
                <div style={{ fontSize: 12, color: "var(--muted)", marginTop: 8 }}>{s.d}</div>
              </div>
          )}
          </div>
        }
      </div>
    </section>);

}

// ───────────────────────────────────────────────────────────────────────────
// Credibility Bar (Hero 직하)
// ───────────────────────────────────────────────────────────────────────────

function CredibilityBar({ accent, surface, t }) {
  const isMobile = useIsMobile();
  if (!t.cred || !t.cred.length) return null;
  const isDarkSurface = surface.bg === "#0f1115";
  const barBg = isDarkSurface ? surface.panel : surface.ink;
  const barFg = surface.bg;
  const labelColor = "rgba(255,255,255,0.62)";
  const dividerColor = "rgba(255,255,255,0.10)";
  return (
    <section aria-label={t.credLabel || "Credentials"} style={{
      borderBottom: "1px solid var(--line)",
      background: barBg,
      color: barFg
    }}>
      <div style={{ maxWidth: 1280, margin: "0 auto", padding: isMobile ? "0 20px" : "0 40px" }}>
        <div style={{
          display: "grid",
          gridTemplateColumns: isMobile ? "1fr 1fr" : `repeat(${t.cred.length}, 1fr)`,
          gap: 0
        }}>
          {t.cred.map((c, i) =>
          <div key={i} style={{
            padding: isMobile ? "20px 14px" : "26px 22px",
            borderLeft: i === 0 || isMobile && i % 2 === 0 ? "none" : `1px solid ${dividerColor}`,
            borderTop: isMobile && i >= 2 ? `1px solid ${dividerColor}` : "none",
            position: "relative"
          }}>
              <div aria-hidden="true" style={{
              position: "absolute",
              top: 0, left: i === 0 || isMobile && i % 2 === 0 ? 0 : -1,
              width: 24, height: 2,
              background: accent
            }}></div>
              <div style={{
              fontSize: isMobile ? 18 : c.v.length > 12 ? 18 : c.v.length > 9 ? 20 : 24,
              fontWeight: 700,
              letterSpacing: "-0.01em",
              color: barFg,
              lineHeight: 1.2,
              wordBreak: "keep-all",
              whiteSpace: "pre-line"
            }}>{c.v}</div>
              <Mono style={{
              fontSize: 10,
              color: labelColor,
              display: "block",
              marginTop: 8,
              letterSpacing: "0.04em"
            }}>{c.l}</Mono>
              {c.s &&
              <Mono style={{
                fontSize: 10,
                color: "rgba(255,255,255,0.38)",
                display: "block",
                marginTop: 4,
                letterSpacing: "0.03em"
              }}>{c.s}</Mono>
              }
            </div>
          )}
        </div>
      </div>
    </section>);

}

// ───────────────────────────────────────────────────────────────────────────
// About / Profile
// ───────────────────────────────────────────────────────────────────────────

function About({ accent, surface, t }) {
  const isMobile = useIsMobile();
  const P = t.profile;
  return (
    <section id="about" style={{ borderBottom: "1px solid var(--line)", padding: isMobile ? "60px 20px" : "96px 40px" }}>
      <div style={{ maxWidth: 1280, margin: "0 auto" }}>
        <SectionLabel index="01" label={t.sec01} accent={accent} />
        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "320px 1fr", gap: isMobile ? 36 : 56, alignItems: "start" }}>
          <div style={{ maxWidth: isMobile ? 260 : "none" }}>
            <div style={{
              width: "100%",
              aspectRatio: "2 / 3",
              border: `1px solid var(--line)`,
              overflow: "hidden",
              background: surface.subtle
            }}>
              <img src={(typeof window !== "undefined" && window.__resources && window.__resources.portrait) || "assets/portrait.png"} alt={P.nameKo}
              style={{ width: "100%", height: "100%", objectFit: "cover", objectPosition: "center", display: "block" }} />
            </div>
            <div style={{ marginTop: 20 }}>
              <div style={{ fontSize: 28, fontWeight: 600, color: "var(--ink)", letterSpacing: "-0.01em" }}>{P.nameKo}</div>
              <Mono style={{ fontSize: 11, color: "var(--muted)" }}>{P.nameEn.toUpperCase()}</Mono>
              <div style={{ marginTop: 14, fontSize: 14, color: "var(--ink)", whiteSpace: "nowrap" }}>{P.title}</div>
              <Mono style={{ fontSize: 11, color: accent, display: "block", marginTop: 4 }}>{P.subtitle}</Mono>
            </div>
          </div>

          <div>
            <p style={{ fontSize: isMobile ? 16 : 19, lineHeight: 1.65, color: "var(--ink)", margin: 0, fontWeight: 400, letterSpacing: "-0.005em", wordBreak: "keep-all", overflowWrap: "break-word", textWrap: "pretty", whiteSpace: "pre-line" }}>
              {P.bio}
            </p>

            <div style={{ marginTop: isMobile ? 40 : 56 }}>
              <Mono style={{ fontSize: 10, color: "var(--muted)", textTransform: "uppercase" }}>{P.certsLabel}</Mono>
              <div style={{ marginTop: 16, display: "grid", gridTemplateColumns: isMobile ? "repeat(2, 1fr)" : `repeat(${P.certs.length}, 1fr)`, gap: 1, background: "var(--line)", border: "1px solid var(--line)" }}>
                {P.certs.map((c, i) => {
                  const lines = c.text.split("\n");
                  return (
                    <div key={i} style={{ background: "var(--panel)", padding: "20px 18px" }}>
                      <Mono style={{ fontSize: 10, color: accent, fontWeight: 600 }}>{c.label.toUpperCase()}</Mono>
                      <div style={{ marginTop: 8, fontSize: 13, lineHeight: 1.4 }}>
                        <div style={{ fontWeight: 600, color: "var(--ink)" }}>{lines[0]}</div>
                        {lines.slice(1).map((line, idx) => (
                          <div key={idx} style={{ color: "var(--muted)", marginTop: 2 }}>{line}</div>
                        ))}
                      </div>
                    </div>
                  );
                })}
              </div>
            </div>

            <div style={{ marginTop: isMobile ? 40 : 56 }}>
              <Mono style={{ fontSize: 10, color: "var(--muted)", textTransform: "uppercase" }}>{P.timelineLabel}</Mono>
              <div style={{ marginTop: 16 }}>
                {P.career.filter((c) => !c.tier || c.tier === "A").map((c, i) =>
                <div key={`a-${i}`} style={{
                  display: "grid",
                  gridTemplateColumns: isMobile ? "1fr" : "180px 1fr 1fr",
                  gap: isMobile ? 4 : 0,
                  padding: "18px 0", borderTop: "1px solid var(--line)",
                  alignItems: isMobile ? "start" : "center"
                }}>
                    <Mono style={{ fontSize: 11, color: accent }}>{c.period}</Mono>
                    <div style={{ fontSize: 15, color: "var(--ink)", fontWeight: 500 }}>{c.org}</div>
                    <div style={{ fontSize: 13, color: "var(--muted)" }}>{c.role}</div>
                  </div>
                )}
                <div style={{ borderTop: "1px solid var(--line)" }}></div>

                {P.career.some((c) => c.tier === "B") &&
                <div style={{ marginTop: 18, paddingTop: 14, borderTop: "1px dashed var(--line)" }}>
                    <Mono style={{ fontSize: 10, color: "var(--muted)", textTransform: "uppercase", letterSpacing: "0.08em" }}>
                      {P.earlierLabel || "Earlier"}
                    </Mono>
                    <div style={{ marginTop: 10, display: "flex", flexDirection: "column", gap: 8 }}>
                      {P.career.filter((c) => c.tier === "B").map((c, i) =>
                    <div key={`b-${i}`} style={{
                      display: "grid",
                      gridTemplateColumns: isMobile ? "1fr" : "180px 1fr 1fr",
                      gap: isMobile ? 2 : 0,
                      alignItems: isMobile ? "start" : "baseline"
                    }}>
                          <Mono style={{ fontSize: 10, color: "var(--muted)" }}>{c.period}</Mono>
                          <div style={{ fontSize: 13, color: "var(--muted)", fontWeight: 500 }}>{c.org}</div>
                          <div style={{ fontSize: 12, color: "var(--muted)", opacity: 0.85 }}>{c.role}</div>
                        </div>
                    )}
                    </div>
                  </div>
                }
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>);

}

// ───────────────────────────────────────────────────────────────────────────
// Domains
// ───────────────────────────────────────────────────────────────────────────

function Domains({ accent, surface, t }) {
  const [hovered, setHovered] = useState(null);
  const isMobile = useIsMobile();
  return (
    <section id="domains" style={{ borderBottom: "1px solid var(--line)", padding: isMobile ? "60px 20px" : "96px 40px", background: surface.subtle }}>
      <div style={{ maxWidth: 1280, margin: "0 auto" }}>
        <SectionLabel index="02" label={t.sec02} accent={accent} />
        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1fr 1fr", gap: isMobile ? 20 : 48, alignItems: "start", marginBottom: isMobile ? 40 : 56 }}>
          <h2 style={{ fontSize: isMobile ? 28 : 40, fontWeight: 600, color: "var(--ink)", letterSpacing: "-0.02em", margin: 0, lineHeight: 1.15 }}>
            {t.domainsHeading}
          </h2>
          <p style={{ fontSize: isMobile ? 14 : 16, lineHeight: 1.65, color: "var(--muted)", margin: 0, paddingTop: isMobile ? 0 : 12 }}>
            {t.domainsBody}
          </p>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "repeat(3, 1fr)", gap: 1, background: "var(--line)", border: "1px solid var(--line)" }}>
          {t.domains.map((d, i) =>
          <div key={d.code}
          onMouseEnter={() => setHovered(i)}
          onMouseLeave={() => setHovered(null)}
          style={{
            background: hovered === i ? "var(--ink)" : "var(--panel)",
            color: hovered === i ? "var(--bg)" : "var(--ink)",
            padding: isMobile ? 24 : 32, transition: "all 0.18s ease",
            cursor: "default", minHeight: isMobile ? "auto" : 280, display: "flex", flexDirection: "column"
          }}>
              <div style={{ display: "flex", justifyContent: "space-between", alignItems: "flex-start" }}>
                <Mono style={{ fontSize: 11, color: hovered === i ? accent : accent, fontWeight: 600 }}>
                  {d.code} / {d.en.toUpperCase()}
                </Mono>
                <Mono style={{ fontSize: 14, opacity: hovered === i ? 1 : 0.3, transition: "opacity 0.18s" }}>→</Mono>
              </div>
              <h3 style={{ fontSize: 18, fontWeight: 600, margin: "20px 0 12px", letterSpacing: "-0.01em", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}>{d.title}</h3>
              <p style={{ fontSize: 14, lineHeight: 1.55, opacity: 0.75, margin: 0 }}>{d.desc}</p>
              <div style={{ marginTop: "auto", paddingTop: 24, display: "flex", flexDirection: "column", gap: 6 }}>
                {d.bullets.map((b, j) =>
              <div key={j} style={{ display: "flex", gap: 10, fontSize: 12, opacity: 0.85 }}>
                    <Mono style={{ opacity: 0.6 }}>·</Mono>
                    <span>{b}</span>
                  </div>
              )}
              </div>
            </div>
          )}
        </div>
      </div>
    </section>);

}

// ───────────────────────────────────────────────────────────────────────────
// Cases
// ───────────────────────────────────────────────────────────────────────────

function Cases({ accent, surface, t }) {
  const [active, setActive] = useState(0);
  const isMobile = useIsMobile();
  const segs = t.portfolioSegments || [];
  const metrics = t.portfolioMetrics || [];
  const s = segs[active] || segs[0];

  return (
    <section id="cases" style={{ borderBottom: "1px solid var(--line)", padding: isMobile ? "60px 20px" : "96px 40px" }}>
      <div style={{ maxWidth: 1280, margin: "0 auto" }}>
        <SectionLabel index="03" label={t.sec03} accent={accent} />

        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1fr 1fr", gap: isMobile ? 20 : 48, alignItems: "start", marginBottom: isMobile ? 40 : 56 }}>
          <h2 style={{ fontSize: isMobile ? 28 : 40, fontWeight: 600, color: "var(--ink)", letterSpacing: "-0.02em", margin: 0, lineHeight: 1.15 }}>
            {t.portfolioHeading}
          </h2>
          <p style={{ fontSize: isMobile ? 14 : 16, lineHeight: 1.65, color: "var(--muted)", margin: 0, paddingTop: isMobile ? 0 : 12, wordBreak: "keep-all" }}>
            {t.portfolioBody}
          </p>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1fr 1.4fr", gap: 0, border: "1px solid var(--line)", background: "var(--panel)" }}>
          {/* Segment list */}
          <div style={{ borderRight: isMobile ? "none" : "1px solid var(--line)", borderBottom: isMobile ? "1px solid var(--line)" : "none" }}>
            <div style={{ padding: "18px 24px", borderBottom: "1px solid var(--line)", background: surface.subtle }}>
              <Mono style={{ fontSize: 10, color: accent, fontWeight: 600, letterSpacing: "0.06em" }}>
                {(t.portfolioSegmentsLabel || "Advisory Segments").toUpperCase()} · {segs.length}
              </Mono>
            </div>
            {segs.map((seg, i) =>
            <button key={i}
              onClick={() => setActive(i)}
              style={{
                width: "100%", textAlign: "left",
                padding: isMobile ? "16px 20px" : "20px 24px",
                background: active === i ? surface.subtle : "transparent",
                border: "none",
                borderBottom: i < segs.length - 1 ? "1px solid var(--line)" : "none",
                borderLeft: active === i ? `3px solid ${accent}` : "3px solid transparent",
                cursor: "pointer", fontFamily: "inherit",
                transition: "background 0.12s, border-color 0.12s",
                display: "block"
              }}>
                <div style={{ display: "flex", alignItems: "baseline", gap: 10 }}>
                  <Mono style={{ fontSize: 10, color: accent, fontWeight: 600 }}>
                    {String(i + 1).padStart(2, "0")}
                  </Mono>
                  <div style={{ fontSize: isMobile ? 13 : 14, fontWeight: active === i ? 600 : 500, color: "var(--ink)", lineHeight: 1.35, letterSpacing: "-0.005em", wordBreak: "keep-all" }}>
                    {seg.title}
                  </div>
                </div>
              </button>
            )}
          </div>

          {/* Detail panel */}
          <div style={{ padding: isMobile ? "28px 22px" : "36px 40px", display: "flex", flexDirection: "column", minHeight: isMobile ? "auto" : 480 }}>
            <div>
              <Mono style={{ fontSize: 10, color: accent, fontWeight: 600 }}>
                {String(active + 1).padStart(2, "0")} / {s.title.toUpperCase()}
              </Mono>
              <p style={{ marginTop: 20, fontSize: isMobile ? 14 : 15, lineHeight: 1.7, color: "var(--ink)", wordBreak: "keep-all" }}>
                {s.summary}
              </p>
            </div>

            <div style={{ marginTop: 28 }}>
              <Mono style={{ fontSize: 10, color: "var(--muted)", textTransform: "uppercase", letterSpacing: "0.05em" }}>
                {t.portfolioActivitiesLabel || "Advisory Activities"}
              </Mono>
              <div style={{ marginTop: 14, display: "flex", flexDirection: "column", gap: 10 }}>
                {(s.activities || []).map((a, i) =>
                <div key={i} style={{ display: "flex", gap: 12, alignItems: "flex-start" }}>
                    <span style={{ color: accent, fontFamily: "'IBM Plex Mono', monospace", fontSize: 12, lineHeight: "22px", flexShrink: 0 }}>→</span>
                    <span style={{ fontSize: 14, lineHeight: 1.55, color: "var(--ink)" }}>{a}</span>
                  </div>
                )}
              </div>
            </div>

            <div style={{ marginTop: 28 }}>
              <Mono style={{ fontSize: 10, color: "var(--muted)", textTransform: "uppercase", letterSpacing: "0.05em" }}>
                {t.portfolioTopicsLabel || "Key Topics"}
              </Mono>
              <div style={{ marginTop: 12, display: "flex", flexWrap: "wrap", gap: 8 }}>
                {(s.topics || "").split(",").map((kw, i) =>
                <div key={i} style={{
                  fontSize: 12, padding: "5px 11px",
                  border: "1px solid var(--line)",
                  color: "var(--muted)", background: surface.subtle,
                  fontFamily: "'IBM Plex Mono', monospace", letterSpacing: "0.02em"
                }}>{kw.trim()}</div>
                )}
              </div>
            </div>


          </div>
        </div>
      </div>
    </section>);

}

// ───────────────────────────────────────────────────────────────────────────
// Recognition — Awards & Publications
// ───────────────────────────────────────────────────────────────────────────

function Recognition({ accent, surface, t }) {
  const isMobile = useIsMobile();
  if (!t.awards || !t.publications) return null;
  return (
    <section id="recognition" style={{ borderBottom: "1px solid var(--line)", padding: isMobile ? "60px 20px" : "96px 40px" }}>
      <div style={{ maxWidth: 1280, margin: "0 auto" }}>
        <SectionLabel index="04" label={t.sec04} accent={accent} />

        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1fr 1fr", gap: isMobile ? 20 : 48, alignItems: "start", marginBottom: isMobile ? 36 : 48 }}>
          <h2 style={{ fontSize: isMobile ? 28 : 40, fontWeight: 600, color: "var(--ink)", letterSpacing: "-0.02em", margin: 0, lineHeight: 1.15 }}>
            {t.recognitionHeading}
          </h2>
          <p style={{ fontSize: isMobile ? 14 : 16, lineHeight: 1.65, color: "var(--muted)", margin: 0, paddingTop: isMobile ? 0 : 12 }}>
            {t.recognitionBody}
          </p>
        </div>

        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1.2fr 1fr", gap: 0, border: "1px solid var(--line)", background: "var(--panel)" }}>
          {/* Awards column */}
          <div style={{ borderRight: isMobile ? "none" : "1px solid var(--line)", borderBottom: isMobile ? "1px solid var(--line)" : "none" }}>
            <div style={{ padding: isMobile ? "18px 22px" : "22px 28px", borderBottom: "1px solid var(--line)", background: surface.subtle, display: "flex", alignItems: "center", justifyContent: "space-between", gap: 12 }}>
              <Mono style={{ fontSize: 10, color: accent, fontWeight: 600, letterSpacing: "0.06em" }}>
                {t.recognitionAwardsLabel.toUpperCase()}
              </Mono>
              <Mono style={{ fontSize: 10, color: "var(--muted)" }}>
                ×{t.awards.length}
              </Mono>
            </div>
            {t.awards.map((a, i) =>
            <div key={i} style={{
              display: "grid",
              gridTemplateColumns: isMobile ? "62px 1fr" : "76px 1fr",
              gap: isMobile ? 14 : 20,
              padding: isMobile ? "20px 22px" : "24px 28px",
              borderBottom: i < t.awards.length - 1 ? "1px solid var(--line)" : "none",
              alignItems: "start"
            }}>
                <div style={{
                fontSize: isMobile ? 22 : 26,
                fontWeight: 600,
                color: accent,
                letterSpacing: "-0.01em",
                lineHeight: 1.05
              }}>{a.year}</div>
                <div>
                  <div style={{ fontSize: isMobile ? 15 : 16, fontWeight: 600, color: "var(--ink)", lineHeight: 1.35 }}>{a.title}</div>
                  <Mono style={{ fontSize: 10, color: "var(--muted)", display: "block", marginTop: 6 }}>
                    {a.org.toUpperCase()}
                  </Mono>
                  {a.note &&
                <div style={{ marginTop: 8, fontSize: 13, color: "var(--muted)", lineHeight: 1.5 }}>{a.note}</div>
                }
                </div>
              </div>
            )}
          </div>

          {/* Publications column */}
          <div>
            <div style={{ padding: isMobile ? "18px 22px" : "22px 28px", borderBottom: "1px solid var(--line)", background: surface.subtle, display: "flex", alignItems: "center", justifyContent: "space-between", gap: 12 }}>
              <Mono style={{ fontSize: 10, color: accent, fontWeight: 600, letterSpacing: "0.06em" }}>
                {t.recognitionPublicationsLabel.toUpperCase()}
              </Mono>
              <Mono style={{ fontSize: 10, color: "var(--muted)" }}>
                ×{t.publications.length}
              </Mono>
            </div>
            {t.publications.map((p, i) =>
            <div key={i} style={{
              padding: isMobile ? "20px 22px" : "24px 28px",
              borderBottom: i < t.publications.length - 1 ? "1px solid var(--line)" : "none"
            }}>
                <div style={{ display: "flex", alignItems: "baseline", gap: 12 }}>
                  <Mono style={{ fontSize: 11, color: accent, fontWeight: 600 }}>{p.year}</Mono>
                  <div style={{ flex: 1, height: 1, background: "var(--line)" }}></div>
                </div>
                <div style={{ marginTop: 10, fontSize: isMobile ? 14 : 15, fontWeight: 500, color: "var(--ink)", lineHeight: 1.4, letterSpacing: "-0.005em" }}>
                  {p.venue}
                </div>
                {p.note &&
              <Mono style={{ marginTop: 8, fontSize: 10, color: "var(--muted)", display: "block", letterSpacing: "0.03em" }}>{p.note}</Mono>
              }
              </div>
            )}
            {t.scholarUrl &&
            <div style={{ padding: isMobile ? "18px 22px" : "22px 28px", borderTop: "1px solid var(--line)" }}>
                <a href={t.scholarUrl} target="_blank" rel="noopener noreferrer"
                style={{
                  display: "inline-flex", alignItems: "center", gap: 10,
                  textDecoration: "none",
                  border: `1px solid ${accent}`,
                  color: accent,
                  padding: "10px 16px",
                  fontFamily: "'IBM Plex Mono', monospace",
                  fontSize: 11, fontWeight: 600, letterSpacing: "0.03em"
                }}>
                  {t.scholarLabel} <span>↗</span>
                </a>
              </div>
            }
          </div>
        </div>
      </div>
    </section>);

}

// ───────────────────────────────────────────────────────────────────────────
// How We Work — engagement formats (공개 캘린더 iframe 제거)
// ───────────────────────────────────────────────────────────────────────────

function Schedule({ accent, surface, t }) {
  const isMobile = useIsMobile();
  const formats = t.scheduleFormats || [];

  return (
    <section id="schedule" style={{ borderBottom: "1px solid var(--line)", padding: isMobile ? "60px 20px" : "96px 40px", background: surface.subtle }}>
      <div style={{ maxWidth: 1280, margin: "0 auto" }}>
        <SectionLabel index="05" label={t.sec05} accent={accent} />

        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1fr 1fr", gap: isMobile ? 20 : 48, alignItems: "start", marginBottom: isMobile ? 36 : 52 }}>
          <h2 style={{ fontSize: isMobile ? 28 : 40, fontWeight: 600, color: "var(--ink)", letterSpacing: "-0.02em", margin: 0, lineHeight: 1.15 }}>
            {t.scheduleHeading}
          </h2>
          <div>
            <p style={{ fontSize: isMobile ? 14 : 16, lineHeight: 1.65, color: "var(--muted)", margin: 0, wordBreak: "keep-all" }}>
              {t.scheduleBody}
            </p>
            <button onClick={() => document.getElementById("contact")?.scrollIntoView({ behavior: "smooth" })}
            style={{
              marginTop: 24, background: "var(--ink)", color: "var(--bg)", border: "none",
              padding: "13px 22px", fontSize: 14, fontWeight: 500, cursor: "pointer",
              fontFamily: "inherit", display: "inline-flex", alignItems: "center", gap: 10
            }}>
              {t.scheduleCtaLabel} <span style={{ fontFamily: "'IBM Plex Mono', monospace" }}>→</span>
            </button>
          </div>
        </div>

        <div>
          <Mono style={{ fontSize: 10, color: "var(--muted)", textTransform: "uppercase", letterSpacing: "0.06em" }}>
            {t.scheduleFormatsLabel}
          </Mono>
          <div style={{ marginTop: 16, display: "grid", gridTemplateColumns: isMobile ? "1fr" : "repeat(2, 1fr)", gap: 1, background: "var(--line)", border: "1px solid var(--line)" }}>
            {formats.map((f, i) =>
            <div key={i} style={{ background: "var(--panel)", padding: isMobile ? "24px 22px" : "30px 32px", display: "flex", gap: isMobile ? 16 : 22, alignItems: "flex-start" }}>
                <Mono style={{ fontSize: 12, color: accent, fontWeight: 600, paddingTop: 4 }}>{f.code}</Mono>
                <div style={{ minWidth: 0 }}>
                  <div style={{ fontSize: isMobile ? 18 : 20, fontWeight: 600, color: "var(--ink)", letterSpacing: "-0.01em" }}>{f.k}</div>
                  <p style={{ margin: "10px 0 0", fontSize: 14, lineHeight: 1.6, color: "var(--muted)", wordBreak: "keep-all" }}>{f.d}</p>
                </div>
              </div>
            )}
          </div>
          {t.scheduleNote &&
          <Mono style={{ display: "block", marginTop: 18, fontSize: 10, color: "var(--muted)", lineHeight: 1.6, wordBreak: "keep-all" }}>
            {t.scheduleNote}
          </Mono>
          }
        </div>
      </div>
    </section>);

}

// ───────────────────────────────────────────────────────────────────────────
// Contact
// ───────────────────────────────────────────────────────────────────────────

function Contact({ accent, surface, t }) {
  const [form, setForm] = useState({
    name: "", company: "", title: "", email: "",
    area: t.domains[1].title, inquiry: t.formInquiryOpts[0],
    timing: "", nda: t.formNdaOpts[0], message: ""
  });
  const [sent, setSent] = useState(false);
  const [errors, setErrors] = useState({});

  // When language changes, reset language-specific select fields to the active language
  useEffect(() => {
    setForm((f) => ({ ...f, area: t.domains[1].title, inquiry: t.formInquiryOpts[0], nda: t.formNdaOpts[0] }));
  }, [t]);

  function submit(e) {
    e.preventDefault();
    const err = {};
    if (!form.name.trim()) err.name = t.err.name;
    if (!form.company.trim()) err.company = t.err.company;
    if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(form.email)) err.email = t.err.email;
    if (form.message.trim().length < 10) err.message = t.err.message;
    setErrors(err);
    if (Object.keys(err).length === 0) {
      const to = "ptk2201@naver.com";
      const ml = t.mailLabels;
      const subject = `${t.mailSubjectPrefix} ${form.company} — ${form.inquiry}`;
      const body =
      `${ml.name}: ${form.name}\n` +
      `${ml.company}: ${form.company}\n` +
      `${ml.title}: ${form.title}\n` +
      `${ml.email}: ${form.email}\n` +
      `${ml.area}: ${form.area}\n` +
      `${ml.inquiry}: ${form.inquiry}\n` +
      `${ml.timing}: ${form.timing}\n` +
      `${ml.nda}: ${form.nda}\n` +
      `\n` +
      `${ml.sep}\n` +
      `${ml.bodyTitle}\n` +
      `${ml.sep}\n` +
      `${form.message}\n`;
      const mailto = `mailto:${to}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
      // window.open is more reliable in sandboxed environments than window.location.href
      try {
        const a = document.createElement('a');
        a.href = mailto;
        a.target = '_blank';
        a.rel = 'noopener';
        document.body.appendChild(a);
        a.click();
        document.body.removeChild(a);
      } catch (_) {
        window.open(mailto, '_blank');
      }
      setSent(mailto);
      setTimeout(() => setSent(false), 8000);
    }
  }

  const inputStyle = {
    width: "100%", padding: "14px 16px",
    background: "transparent",
    border: "1px solid var(--line)",
    color: "var(--ink)",
    fontSize: 14, fontFamily: "inherit",
    outline: "none",
    transition: "border-color 0.15s"
  };

  const isMobile = useIsMobile();

  return (
    <section id="contact" style={{ padding: isMobile ? "60px 20px" : "96px 40px", background: surface.subtle, borderBottom: "1px solid var(--line)" }}>
      <div style={{ maxWidth: 1280, margin: "0 auto" }}>
        <SectionLabel index="05" label={t.sec06} accent={accent} />

        <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1fr 1.2fr", gap: isMobile ? 40 : 64 }}>
          <div>
            <h2 style={{ fontSize: isMobile ? 28 : 40, fontWeight: 600, color: "var(--ink)", letterSpacing: "-0.02em", margin: 0, lineHeight: 1.15 }}>
              {t.contactHeading}
            </h2>
            <div style={{ marginTop: 24 }}>
              {(t.contactBody || "").split("\n\n").map((para, i) =>
              <p key={i} style={{ fontSize: 15, lineHeight: 1.7, color: "var(--muted)", margin: i > 0 ? "14px 0 0" : 0, wordBreak: "keep-all" }}>
                  {para}
                </p>
              )}
            </div>

            {t.contactSteps &&
            <div style={{ marginTop: 36, border: "1px solid var(--line)", background: "var(--panel)" }}>
                {t.contactSteps.map((step, i) =>
                <div key={i} style={{
                  display: "flex", alignItems: "flex-start", gap: 16,
                  padding: "18px 20px",
                  borderBottom: i < t.contactSteps.length - 1 ? "1px solid var(--line)" : "none"
                }}>
                    <div style={{
                    width: 36, height: 36, borderRadius: "50%",
                    background: accent, flexShrink: 0,
                    display: "flex", alignItems: "center", justifyContent: "center"
                  }}>
                      <Mono style={{ fontSize: 11, color: "#fff", fontWeight: 700 }}>{step.n}</Mono>
                    </div>
                    <div style={{ flex: 1, minWidth: 0 }}>
                      <div style={{ fontSize: 15, fontWeight: 600, color: "var(--ink)", lineHeight: 1.3 }}>{step.k}</div>
                      <div style={{ marginTop: 4, fontSize: 13, color: "var(--muted)", lineHeight: 1.5, wordBreak: "keep-all" }}>{step.d}</div>
                    </div>
                    <Mono style={{ fontSize: 12, color: "var(--muted)", paddingTop: 11 }}>›</Mono>
                  </div>
                )}
              </div>
            }
          </div>

          <div>
            <form onSubmit={submit} style={{ background: "var(--panel)", border: "1px solid var(--line)", padding: isMobile ? 24 : 40 }}>
              <div style={{ display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1fr 1fr", gap: 20 }}>
                <Field label={t.formName} error={errors.name}>
                  <input style={inputStyle} value={form.name} onChange={(e) => setForm({ ...form, name: e.target.value })} placeholder={t.formNamePh} />
                </Field>
                <Field label={t.formCompany} error={errors.company}>
                  <input style={inputStyle} value={form.company} onChange={(e) => setForm({ ...form, company: e.target.value })} placeholder={t.formCompanyPh} />
                </Field>
              </div>
              <div style={{ marginTop: 20, display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1fr 1fr", gap: 20 }}>
                <Field label={t.formTitle}>
                  <input style={inputStyle} value={form.title} onChange={(e) => setForm({ ...form, title: e.target.value })} placeholder={t.formTitlePh} />
                </Field>
                <Field label={t.formEmail} error={errors.email}>
                  <input type="email" style={inputStyle} value={form.email} onChange={(e) => setForm({ ...form, email: e.target.value })} placeholder={t.formEmailPh} />
                </Field>
              </div>
              <div style={{ marginTop: 20, display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1fr 1fr", gap: 20 }}>
                <Field label={t.formInquiry}>
                  <select style={{ ...inputStyle, appearance: "none" }} value={form.inquiry} onChange={(e) => setForm({ ...form, inquiry: e.target.value })}>
                    {t.formInquiryOpts.map((o) => <option key={o}>{o}</option>)}
                  </select>
                </Field>
                <Field label={t.formArea}>
                  <select style={{ ...inputStyle, appearance: "none" }} value={form.area} onChange={(e) => setForm({ ...form, area: e.target.value })}>
                    {t.domains.map((d) => <option key={d.code}>{d.title}</option>)}
                    <option>{t.domainOtherArea}</option>
                  </select>
                </Field>
              </div>
              <div style={{ marginTop: 20 }}>
                <Field label={t.formMessage} error={errors.message}>
                  <textarea style={{ ...inputStyle, minHeight: 140, resize: "vertical", fontFamily: "inherit" }}
                  value={form.message}
                  onChange={(e) => setForm({ ...form, message: e.target.value })}
                  placeholder={t.formMessagePh} />
                </Field>
              </div>
              <div style={{ marginTop: 20, display: "grid", gridTemplateColumns: isMobile ? "1fr" : "1fr 1fr", gap: 20 }}>
                <Field label={t.formTiming}>
                  <input style={inputStyle} value={form.timing} onChange={(e) => setForm({ ...form, timing: e.target.value })} placeholder={t.formTimingPh} />
                </Field>
                <Field label={t.formNda}>
                  <select style={{ ...inputStyle, appearance: "none" }} value={form.nda} onChange={(e) => setForm({ ...form, nda: e.target.value })}>
                    {t.formNdaOpts.map((o) => <option key={o}>{o}</option>)}
                  </select>
                </Field>
              </div>

              <div style={{ marginTop: 28 }}>
                <button type="submit" style={{
                  background: sent ? accent : "var(--ink)", color: "var(--bg)",
                  border: "none", padding: "16px 28px",
                  fontSize: 15, fontWeight: 500, cursor: "pointer",
                  fontFamily: "inherit", display: "flex", alignItems: "center", gap: 10,
                  transition: "background 0.2s",
                  width: "100%",
                  justifyContent: "center",
                  whiteSpace: "nowrap"
                }}>
                  {sent ? t.formSent : <>{t.formSubmit} <Mono>→</Mono></>}
                </button>
                {sent &&
                <a href={sent} style={{
                  display: "block", textAlign: "center", marginTop: 8,
                  fontFamily: "'IBM Plex Mono', monospace", fontSize: 10,
                  color: accent, textDecoration: "underline", wordBreak: "break-all"
                }}>
                  {t.formMailFallback || "메일 앱이 열리지 않으면 여기를 클릭"}
                </a>
                }
                <Mono style={{ display: "block", textAlign: "center", marginTop: 12, fontSize: 10, color: "var(--muted)" }}>
                  {t.formNote}
                </Mono>
              </div>
            </form>
          </div>
        </div>
      </div>
    </section>);

}

function Field({ label, error, children }) {
  return (
    <label style={{ display: "block" }}>
      <div style={{ display: "flex", justifyContent: "space-between", alignItems: "baseline", marginBottom: 8 }}>
        <Mono style={{ fontSize: 10, color: "var(--muted)", textTransform: "uppercase", fontWeight: 600 }}>{label}</Mono>
        {error && <span style={{ fontSize: 11, color: "#c0392b" }}>{error}</span>}
      </div>
      {children}
    </label>);

}

// ───────────────────────────────────────────────────────────────────────────
// Footer
// ───────────────────────────────────────────────────────────────────────────

function Footer({ accent, t }) {
  const isMobile = useIsMobile();
  return (
    <footer style={{ padding: isMobile ? "28px 20px" : "40px 40px", borderTop: "1px solid var(--line)", background: "var(--bg)" }}>
      <div style={{ maxWidth: 1280, margin: "0 auto", display: "flex", justifyContent: "space-between", alignItems: "center", flexWrap: "wrap", gap: 16 }}>
        <div>
          <Mono style={{ fontSize: 10, color: "var(--muted)", display: "block" }}>
            {t.footerLeft}
          </Mono>
          <Mono style={{ fontSize: 9, color: "var(--muted)", opacity: 0.5, display: "block", marginTop: 4, letterSpacing: "0.02em" }}>
            Website by Sim WonJun
          </Mono>
        </div>
        <Mono style={{ fontSize: 10, color: "var(--muted)" }}>
          {t.footerRight}
        </Mono>
      </div>
    </footer>);

}

// ───────────────────────────────────────────────────────────────────────────
// Tweaks
// ───────────────────────────────────────────────────────────────────────────

function Tweaks({ tweaks, setTweak, t }) {
  return (
    <TweaksPanel title={t.tweaksTitle}>
      <TweakSection title={t.tweakSecColor}>
        <TweakColor label={t.tweakAccent} value={tweaks.accent} onChange={(v) => setTweak("accent", v)}
        options={["#1f4ed8", "#d97757", "#1f8a5b", "#7c3aed"]} />
        <TweakRadio label={t.tweakSurface} value={tweaks.surface} onChange={(v) => setTweak("surface", v)}
        options={t.tweakSurfaceOpts} />
      </TweakSection>
      <TweakSection title={t.tweakSecLayout}>
        <TweakRadio label={t.tweakHero} value={tweaks.headerStyle} onChange={(v) => setTweak("headerStyle", v)}
        options={t.tweakHeroOpts} />
        <TweakRadio label={t.tweakDensity} value={tweaks.density} onChange={(v) => setTweak("density", v)}
        options={t.tweakDensityOpts} />
      </TweakSection>
    </TweaksPanel>);

}

// ───────────────────────────────────────────────────────────────────────────
// App
// ───────────────────────────────────────────────────────────────────────────

function App() {
  const [tweaks, setTweak] = useTweaks(TWEAK_DEFAULTS);
  const [lang, setLangState] = useState(() => {
    if (typeof window === "undefined") return "ko";
    try {
      const saved = window.localStorage.getItem("lang");
      if (saved === "ko" || saved === "en") return saved;
    } catch (_) {}
    return "ko";
  });
  const t = I18N[lang] || I18N.ko;

  function setLang(next) {
    setLangState(next);
    try {window.localStorage.setItem("lang", next);} catch (_) {}
  }

  // Update <html lang> + <title> on language change
  useEffect(() => {
    if (typeof document !== "undefined") {
      document.documentElement.setAttribute("lang", lang === "en" ? "en" : "ko");
      if (t.docTitle) document.title = t.docTitle;
    }
  }, [lang, t]);

  const surface = SURFACES[tweaks.surface] || SURFACES.warm;
  const accent = tweaks.accent;

  function jump(id) {
    const el = document.getElementById(id);
    if (el) {
      const y = el.getBoundingClientRect().top + window.scrollY - 60;
      window.scrollTo({ top: y, behavior: "smooth" });
    }
  }

  const cssVars = {
    "--bg": surface.bg,
    "--panel": surface.panel,
    "--ink": surface.ink,
    "--muted": surface.muted,
    "--line": surface.line,
    "--accent": accent
  };

  return (
    <div style={{ ...cssVars, background: surface.bg, color: surface.ink, minHeight: "100vh", fontFamily: "'Pretendard', 'Pretendard Variable', -apple-system, sans-serif" }}>
      <TopBar accent={accent} onJump={jump} t={t} lang={lang} setLang={setLang} />
      <Hero accent={accent} surface={surface} headerStyle={tweaks.headerStyle} density={tweaks.density} t={t} />
      <CredibilityBar accent={accent} surface={surface} t={t} />
      <About accent={accent} surface={surface} t={t} />
      <Domains accent={accent} surface={surface} t={t} />
      <Cases accent={accent} surface={surface} t={t} />
      <Recognition accent={accent} surface={surface} t={t} />
      <Contact accent={accent} surface={surface} t={t} />
      <Footer accent={accent} t={t} />
      <Tweaks tweaks={tweaks} setTweak={setTweak} t={t} />
    </div>);

}

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);