// Shell: TopNav, PageShell, Icons, shared UI atoms
// -------------------------------------------------------

const Icon = ({ name, size = 20, color = "currentColor", stroke = 1.75 }) => {
  const paths = {
    menu: <><line x1="4" y1="7" x2="20" y2="7"/><line x1="4" y1="12" x2="20" y2="12"/><line x1="4" y1="17" x2="20" y2="17"/></>,
    search: <><circle cx="11" cy="11" r="7"/><line x1="16.5" y1="16.5" x2="21" y2="21"/></>,
    user: <><circle cx="12" cy="8" r="4"/><path d="M4 21c0-4.4 3.6-8 8-8s8 3.6 8 8"/></>,
    bell: <><path d="M6 8a6 6 0 1 1 12 0c0 7 3 8 3 8H3s3-1 3-8"/><path d="M10.3 20a1.94 1.94 0 0 0 3.4 0"/></>,
    chevronR: <><polyline points="9 6 15 12 9 18"/></>,
    chevronL: <><polyline points="15 6 9 12 15 18"/></>,
    chevronD: <><polyline points="6 9 12 15 18 9"/></>,
    play: <><polygon points="6 4 20 12 6 20 6 4" fill="currentColor" stroke="none"/></>,
    pause: <><rect x="6" y="4" width="4" height="16" fill="currentColor" stroke="none"/><rect x="14" y="4" width="4" height="16" fill="currentColor" stroke="none"/></>,
    cc: <><rect x="3" y="5" width="18" height="14" rx="2"/><path d="M10 10a2 2 0 0 0-3 2 2 2 0 0 0 3 2M17 10a2 2 0 0 0-3 2 2 2 0 0 0 3 2"/></>,
    volume: <><polygon points="4 9 8 9 12 5 12 19 8 15 4 15 4 9" fill="currentColor" stroke="none"/><path d="M16 8a5 5 0 0 1 0 8M19 5a9 9 0 0 1 0 14"/></>,
    sparkle: <><path d="M12 3l1.5 5.5L19 10l-5.5 1.5L12 17l-1.5-5.5L5 10l5.5-1.5L12 3z" fill="currentColor" stroke="none"/><path d="M19 17l0.8 2.2L22 20l-2.2 0.8L19 23l-0.8-2.2L16 20l2.2-0.8z" fill="currentColor" stroke="none"/></>,
    check: <><polyline points="4 12 10 18 20 6"/></>,
    x: <><line x1="5" y1="5" x2="19" y2="19"/><line x1="19" y1="5" x2="5" y2="19"/></>,
    mic: <><rect x="9" y="3" width="6" height="12" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3M8 21h8"/></>,
    volume2: <><polygon points="4 9 8 9 12 5 12 19 8 15 4 15 4 9" fill="currentColor" stroke="none"/><path d="M16 8a5 5 0 0 1 0 8"/></>,
    send: <><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></>,
    book: <><path d="M4 4h7a3 3 0 0 1 3 3v13a2 2 0 0 0-2-2H4zM20 4h-7a3 3 0 0 0-3 3v13a2 2 0 0 1 2-2h8z"/></>,
    calendar: <><rect x="4" y="5" width="16" height="16" rx="2"/><line x1="4" y1="10" x2="20" y2="10"/><line x1="9" y1="3" x2="9" y2="7"/><line x1="15" y1="3" x2="15" y2="7"/></>,
    award: <><circle cx="12" cy="9" r="6"/><path d="M8.5 13.5L7 22l5-3 5 3-1.5-8.5"/></>,
    briefcase: <><rect x="3" y="7" width="18" height="13" rx="2"/><path d="M8 7V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="3" y1="12" x2="21" y2="12"/></>,
    text: <><path d="M4 6h16M4 12h16M4 18h10"/></>,
    eye: <><path d="M1 12s4-7 11-7 11 7 11 7-4 7-11 7-11-7-11-7z"/><circle cx="12" cy="12" r="3"/></>,
    ear: <><path d="M6 8a6 6 0 1 1 12 0c0 2-1 3-2 4s-2 2-2 4a3 3 0 0 1-6 0"/></>,
    brain: <><path d="M9 3a3 3 0 0 0-3 3v1a3 3 0 0 0-2 3 3 3 0 0 0 1 2 3 3 0 0 0 0 3 3 3 0 0 0 3 3 2 2 0 0 0 4 0V3a2 2 0 0 0-3 0zM15 3a3 3 0 0 1 3 3v1a3 3 0 0 1 2 3 3 3 0 0 1-1 2 3 3 0 0 1 0 3 3 3 0 0 1-3 3 2 2 0 0 1-4 0V3a2 2 0 0 1 3 0z"/></>,
    puzzle: <><path d="M19.5 12a2.5 2.5 0 0 0 0-5H18V5a2 2 0 0 0-2-2h-2v1.5a2.5 2.5 0 0 1-5 0V3H7a2 2 0 0 0-2 2v2H3.5a2.5 2.5 0 0 0 0 5H5v2H3.5a2.5 2.5 0 0 0 0 5H5v2a2 2 0 0 0 2 2h2v-1.5a2.5 2.5 0 0 1 5 0V21h2a2 2 0 0 0 2-2v-2h1.5a2.5 2.5 0 0 0 0-5H18v-2h1.5"/></>,
    home: <><path d="M3 10l9-7 9 7v10a2 2 0 0 1-2 2h-3v-7h-8v7H5a2 2 0 0 1-2-2z"/></>,
    help: <><circle cx="12" cy="12" r="9"/><path d="M9.5 9a2.5 2.5 0 0 1 5 0c0 2-2.5 2-2.5 4M12 17.5v0.5"/></>,
    filter: <><polygon points="4 4 20 4 14 12 14 19 10 21 10 12 4 4"/></>,
    clock: <><circle cx="12" cy="12" r="9"/><polyline points="12 7 12 12 15 14"/></>,
    users: <><circle cx="9" cy="8" r="4"/><path d="M2 21c0-4 3-7 7-7s7 3 7 7"/><circle cx="17" cy="6" r="3"/><path d="M22 17c0-2.5-2-4.5-5-4.5"/></>,
    refresh: <><polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.5 9a9 9 0 0 1 15-3.4L23 10M1 14l4.5 4.4A9 9 0 0 0 20.5 15"/></>,
    alert: <><path d="M12 3 2 21h20z"/><line x1="12" y1="10" x2="12" y2="14"/><circle cx="12" cy="17" r="0.5" fill="currentColor"/></>,
    sliders: <><line x1="4" y1="21" x2="4" y2="14"/><line x1="4" y1="10" x2="4" y2="3"/><line x1="12" y1="21" x2="12" y2="12"/><line x1="12" y1="8" x2="12" y2="3"/><line x1="20" y1="21" x2="20" y2="16"/><line x1="20" y1="12" x2="20" y2="3"/><line x1="1" y1="14" x2="7" y2="14"/><line x1="9" y1="8" x2="15" y2="8"/><line x1="17" y1="16" x2="23" y2="16"/></>,
    download: <><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></>,
    arrowR: <><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></>,
    shield: <><path d="M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6l8-3z"/></>,
    image: <><rect x="3" y="5" width="18" height="14" rx="2"/><circle cx="9" cy="11" r="2"/><polyline points="21 17 15 11 3 19"/></>,
    star: <><polygon points="12 2 15 9 22 10 17 15 18 22 12 18 6 22 7 15 2 10 9 9 12 2" fill="currentColor" stroke="none"/></>,
  };
  const p = paths[name];
  if (!p) return null;
  return (
    <svg width={size} height={size} viewBox="0 0 24 24" fill="none"
      stroke={color} strokeWidth={stroke} strokeLinecap="round" strokeLinejoin="round"
      style={{ flexShrink: 0 }} aria-hidden="true">
      {p}
    </svg>
  );
};

// Feature badge (non-stigmatizing) — describes what the course HAS, not who it's for
const FeatureBadge = ({ type, size = 14 }) => {
  const map = {
    tts:      { label: "語音服務", color: "#1f4a7a", bg: "#e0ebf6", icon: "volume" },
    caption:  { label: "字幕逐字稿", color: "#0d6b88", bg: "#def0f5", icon: "cc" },
    easy:     { label: "易讀版", color: "#8b5a0b", bg: "#fbf0d8", icon: "book" },
    multi:    { label: "多感官學習", color: "#5b3db5", bg: "#ece7f7", icon: "puzzle" },
    sign:     { label: "手語輔助", color: "#8b2555", bg: "#fae3ec", icon: "users" },
    keyboard: { label: "全鍵盤操作", color: "#2d5f2d", bg: "#e3efe0", icon: "sliders" },
  };
  const d = map[type];
  if (!d) return null;
  return (
    <span style={{
      display: "inline-flex", alignItems: "center", gap: 4,
      padding: "3px 8px", borderRadius: 999,
      background: d.bg, color: d.color,
      fontSize: "var(--fs-xs)", fontWeight: 600,
    }}>
      <Icon name={d.icon} size={size - 2} color={d.color} />
      {d.label}
    </span>
  );
};

// Legacy disability badge kept for backward-compat but not used in course cards
const DisabilityBadge = ({ type, size = 14 }) => {
  const map = {
    VI: { label: "視障", color: "#5b3db5", bg: "#ece7f7", icon: "eye" },
    HI: { label: "聽障", color: "#0d6b88", bg: "#def0f5", icon: "ear" },
    CI: { label: "認知障礙", color: "#8b5a0b", bg: "#fbf0d8", icon: "puzzle" },
    LD: { label: "學習障礙", color: "#8b2555", bg: "#fae3ec", icon: "brain" },
  };
  const d = map[type];
  if (!d) return null;
  return (
    <span style={{
      display: "inline-flex", alignItems: "center", gap: 4,
      padding: "3px 8px", borderRadius: 999,
      background: d.bg, color: d.color,
      fontSize: "var(--fs-xs)", fontWeight: 600,
    }}>
      <Icon name={d.icon} size={size - 2} color={d.color} />
      {d.label}
    </span>
  );
};

const Button = ({ children, variant = "primary", size = "md", onClick, icon, disabled, style = {}, type = "button" }) => {
  const sizes = {
    sm: { padding: "6px 12px", fontSize: "var(--fs-sm)", gap: 6, minHeight: 32 },
    md: { padding: "10px 18px", fontSize: "var(--fs-base)", gap: 8, minHeight: 44 },
    lg: { padding: "14px 24px", fontSize: "var(--fs-lg)", gap: 10, minHeight: 52 },
  };
  const variants = {
    primary: { background: "var(--brand)", color: "#fff", border: "1.5px solid var(--brand)" },
    secondary: { background: "#fff", color: "var(--brand)", border: "1.5px solid var(--brand)" },
    ghost: { background: "transparent", color: "var(--ink-2)", border: "1.5px solid var(--border-strong)" },
    accent: { background: "var(--accent)", color: "#fff", border: "1.5px solid var(--accent)" },
    danger: { background: "#fff", color: "var(--danger)", border: "1.5px solid var(--danger)" },
  };
  const [hover, setHover] = React.useState(false);
  return (
    <button
      type={type}
      onClick={onClick}
      disabled={disabled}
      onMouseEnter={() => setHover(true)}
      onMouseLeave={() => setHover(false)}
      style={{
        display: "inline-flex", alignItems: "center", justifyContent: "center",
        fontWeight: 600, fontFamily: "inherit",
        borderRadius: "var(--radius-sm)",
        cursor: disabled ? "not-allowed" : "pointer",
        opacity: disabled ? 0.5 : 1,
        transition: "all 150ms ease",
        filter: hover && !disabled ? "brightness(0.92)" : "none",
        transform: hover && !disabled ? "translateY(-1px)" : "none",
        boxShadow: hover && !disabled ? "var(--shadow-sm)" : "none",
        ...sizes[size], ...variants[variant], ...style,
      }}
    >
      {icon && <Icon name={icon} size={18} />}
      {children}
    </button>
  );
};

// Tag — 狀態徽章（WCAG 1.4.1：不只靠顏色傳達資訊，每個狀態都有獨特形狀 + 圖示）
const Tag = ({ children, color = "ink", style = {}, icon, shape }) => {
  // status colors have explicit shapes (border style + icon) so colorblind users can distinguish
  const colors = {
    ink:    { bg: "var(--bg-2)",      fg: "var(--ink-2)",      border: "1px solid var(--border-strong)",              icon: null,     radius: 6 },
    brand:  { bg: "var(--brand-100)", fg: "var(--brand-600)",  border: "1px solid var(--brand)",                      icon: null,     radius: 6 },
    accent: { bg: "var(--accent-100)",fg: "var(--accent-600)", border: "1px solid var(--accent)",                     icon: null,     radius: 999 },
    ok:     { bg: "var(--ok-100)",    fg: "var(--ok)",         border: "1.5px solid var(--ok)",                       icon: "check",  radius: 6 },
    warn:   { bg: "var(--warn-100)",  fg: "var(--warn)",       border: "1.5px dashed var(--warn)",                    icon: "alert",  radius: 2 },
    danger: { bg: "var(--danger-100)",fg: "var(--danger)",     border: "2px solid var(--danger)",                     icon: "x",      radius: 2 },
  };
  const c = colors[color] || colors.ink;
  const iconToRender = icon === false ? null : (icon || c.icon);
  return (
    <span style={{
      display: "inline-flex", alignItems: "center", gap: 4,
      padding: "3px 10px", borderRadius: shape ?? c.radius,
      background: c.bg, color: c.fg, border: c.border,
      fontSize: "var(--fs-xs)", fontWeight: 700,
      letterSpacing: "0.02em", whiteSpace: "nowrap",
      ...style,
    }}>
      {iconToRender && <Icon name={iconToRender} size={11} color={c.fg} stroke={2.5} />}
      {children}
    </span>
  );
};

const Card = ({ children, style = {}, hover = false, onClick }) => {
  const [h, setH] = React.useState(false);
  return (
    <div
      onClick={onClick}
      onMouseEnter={() => setH(true)}
      onMouseLeave={() => setH(false)}
      style={{
        background: "var(--paper)",
        border: "1px solid var(--border)",
        borderRadius: "var(--radius)",
        boxShadow: hover && h ? "var(--shadow)" : "var(--shadow-sm)",
        transform: hover && h ? "translateY(-2px)" : "none",
        transition: "all 180ms ease",
        cursor: onClick ? "pointer" : "default",
        ...style,
      }}
    >
      {children}
    </div>
  );
};

// Top navigation
const TopNav = ({ page, setPage, user, onOpenAI, notificationCount = 2 }) => {
  const { profile, toggleFlag } = useA11y();
  const ttsOn = !!profile.flags?.tts_default;
  const links = [
    { id: "home", label: "首頁" },
    { id: "catalog", label: "課程總覽" },
    { id: "events", label: "活動與同步教學" },
    { id: "dashboard", label: "我的學習" },
  ];
  return (
    <header style={{
      background: "var(--paper)",
      borderBottom: "1px solid var(--border)",
      position: "sticky", top: 0, zIndex: 40,
    }}>
      {/* Gov top bar */}
      <div style={{
        background: "var(--ink)", color: "#cfd7e5",
        fontSize: "var(--fs-xs)",
        padding: "6px 0",
      }}>
        <div style={{ maxWidth: 1280, margin: "0 auto", padding: "0 24px", display: "flex", gap: 20, alignItems: "center" }}>
          <span>勞動部 勞動力發展署</span>
          <span style={{ opacity: 0.5 }}>|</span>
          <span>回首頁</span>
          <span style={{ opacity: 0.5 }}>|</span>
          <span>網站導覽</span>
          <span style={{ marginLeft: "auto", opacity: 0.7 }}>服務電話：0800-777-888（免付費）</span>
        </div>
      </div>
      <div style={{
        maxWidth: 1280, margin: "0 auto", padding: "14px 24px",
        display: "flex", alignItems: "center", gap: 32,
      }}>
        <div
          onClick={() => setPage("home")}
          style={{ display: "flex", alignItems: "center", gap: 12, cursor: "pointer" }}
        >
          <div style={{
            width: 44, height: 44, borderRadius: 10,
            background: "linear-gradient(135deg, var(--brand) 0%, var(--brand-600) 100%)",
            display: "flex", alignItems: "center", justifyContent: "center",
            color: "#fff", fontWeight: 900, fontSize: "var(--fs-xl)",
            letterSpacing: "-0.05em",
          }}>
            e
          </div>
          <div>
            <div style={{ fontSize: "var(--fs-lg)", fontWeight: 700, letterSpacing: "-0.01em", lineHeight: 1.1 }}>
              無礙 e 網
            </div>
            <div style={{ fontSize: "var(--fs-xs)", color: "var(--muted)", marginTop: 1 }}>
              身心障礙者數位學習平台
            </div>
          </div>
        </div>

        <nav style={{ display: "flex", gap: 4, marginLeft: 8 }}>
          {links.map(l => (
            <button
              key={l.id}
              onClick={() => setPage(l.id)}
              style={{
                padding: "10px 16px",
                background: page === l.id ? "var(--brand-100)" : "transparent",
                color: page === l.id ? "var(--brand-600)" : "var(--ink-2)",
                border: "none", borderRadius: 6,
                fontSize: "var(--fs-base)", fontWeight: page === l.id ? 700 : 500,
                fontFamily: "inherit",
              }}
            >
              {l.label}
            </button>
          ))}
        </nav>

        <div style={{ marginLeft: "auto", display: "flex", alignItems: "center", gap: 8 }}>
          <button
            onClick={() => { ttsCancel(); toggleFlag("tts_default"); }}
            aria-pressed={ttsOn}
            aria-label={ttsOn ? "關閉自動朗讀" : "開啟自動朗讀"}
            title={ttsOn ? "自動朗讀：開啟中（點擊關閉）" : "自動朗讀：關閉（點擊開啟）"}
            style={{
              display: "inline-flex", alignItems: "center", gap: 6,
              padding: "8px 12px", minHeight: 40,
              background: ttsOn ? "var(--brand)" : "var(--bg-2)",
              color: ttsOn ? "#fff" : "var(--ink-2)",
              border: `1.5px solid ${ttsOn ? "var(--brand)" : "var(--border)"}`,
              borderRadius: 8, fontWeight: 700, fontSize: "var(--fs-sm)",
              fontFamily: "inherit", cursor: "pointer",
            }}
          >
            <Icon name="volume" size={16} color={ttsOn ? "#fff" : "var(--ink-2)"} />
            朗讀 {ttsOn ? "開" : "關"}
          </button>
          <IconBtn name="search" label="搜尋" />
          <IconBtn name="bell" label="通知" badge={notificationCount} />
          <button
            onClick={onOpenAI}
            style={{
              display: "inline-flex", alignItems: "center", gap: 8,
              padding: "9px 14px", minHeight: 40,
              background: "var(--accent)", color: "#fff",
              border: "none", borderRadius: 8,
              fontWeight: 700, fontSize: "var(--fs-sm)",
              fontFamily: "inherit", cursor: "pointer",
            }}
          >
            <Icon name="sparkle" size={16} />
            AI 助教
          </button>
          <button
            onClick={() => setPage("dashboard")}
            style={{
              display: "flex", alignItems: "center", gap: 8,
              padding: "6px 12px 6px 6px", borderRadius: 999,
              background: "var(--bg-2)", border: "1px solid var(--border)",
              fontFamily: "inherit", fontSize: "var(--fs-sm)", fontWeight: 600,
            }}
          >
            <div style={{
              width: 32, height: 32, borderRadius: "50%",
              background: "linear-gradient(135deg, #f0b06a, #e8743c)",
              display: "flex", alignItems: "center", justifyContent: "center",
              color: "#fff", fontWeight: 700,
            }}>
              {user?.initial || "林"}
            </div>
            <span style={{ color: "var(--ink-2)" }}>{user?.name || "林同學"}</span>
          </button>
        </div>
      </div>
    </header>
  );
};

const IconBtn = ({ name, label, badge, onClick }) => (
  <button
    onClick={onClick}
    aria-label={label}
    style={{
      position: "relative",
      width: 40, height: 40,
      display: "flex", alignItems: "center", justifyContent: "center",
      background: "transparent", border: "1px solid transparent",
      borderRadius: 8, color: "var(--ink-2)",
      fontFamily: "inherit",
    }}
    onMouseEnter={e => e.currentTarget.style.background = "var(--bg-2)"}
    onMouseLeave={e => e.currentTarget.style.background = "transparent"}
  >
    <Icon name={name} size={20} />
    {badge > 0 && (
      <span style={{
        position: "absolute", top: 6, right: 6,
        minWidth: 16, height: 16, padding: "0 4px",
        borderRadius: 999,
        background: "var(--accent)", color: "#fff",
        fontSize: 10, fontWeight: 700,
        display: "flex", alignItems: "center", justifyContent: "center",
        border: "1.5px solid #fff",
      }}>{badge}</span>
    )}
  </button>
);

// Footer
const Footer = () => (
  <footer style={{
    borderTop: "1px solid var(--border)",
    background: "var(--paper)",
    padding: "40px 24px 32px",
    marginTop: 60,
  }}>
    <div style={{ maxWidth: 1280, margin: "0 auto" }}>
      <div style={{ display: "grid", gridTemplateColumns: "1.4fr 1fr 1fr 1fr", gap: 40 }}>
        <div>
          <div style={{ display: "flex", gap: 10, alignItems: "center" }}>
            <div style={{
              width: 32, height: 32, borderRadius: 8,
              background: "linear-gradient(135deg, var(--brand) 0%, var(--brand-600) 100%)",
              display: "flex", alignItems: "center", justifyContent: "center",
              color: "#fff", fontWeight: 900,
            }}>e</div>
            <div style={{ fontWeight: 700, fontSize: "var(--fs-base)" }}>無礙 e 網</div>
          </div>
          <p style={{ color: "var(--muted)", fontSize: "var(--fs-sm)", marginTop: 12, lineHeight: 1.7 }}>
            提供身心障礙者無障礙數位學習服務。通過 WCAG 2.1 AAA 認證，支援視障、聽障、認知障礙、學習障礙四大類型學員。
          </p>
          <div style={{ display: "flex", gap: 8, marginTop: 16 }}>
            <Tag color="ok">WCAG 2.1 AAA</Tag>
            <Tag color="brand">AI 助教</Tag>
          </div>
        </div>
        <FooterCol title="關於平台" items={["服務介紹", "無障礙聲明", "隱私權政策", "著作權聲明"]} />
        <FooterCol title="學習資源" items={["全部課程", "易讀版課程", "同步教學", "職涯資源"]} />
        <FooterCol title="客戶服務" items={["聯絡我們", "0800-777-888", "service@wda-learn.gov.tw", "轉人工助教"]} />
      </div>
      <div style={{
        marginTop: 36, paddingTop: 20,
        borderTop: "1px solid var(--border)",
        display: "flex", justifyContent: "space-between",
        color: "var(--muted)", fontSize: "var(--fs-xs)",
      }}>
        <span>© 2026 勞動部勞動力發展署 All Rights Reserved</span>
        <span>最後更新：2026 / 04 / 19　｜　標案號 wda1150008</span>
      </div>
    </div>
  </footer>
);

const FooterCol = ({ title, items }) => (
  <div>
    <div style={{ fontWeight: 700, fontSize: "var(--fs-sm)", marginBottom: 14, color: "var(--ink)" }}>{title}</div>
    <ul style={{ listStyle: "none", padding: 0, margin: 0, display: "flex", flexDirection: "column", gap: 10 }}>
      {items.map(i => (
        <li key={i}>
          <a href="#" style={{ color: "var(--ink-soft)", fontSize: "var(--fs-sm)" }}>{i}</a>
        </li>
      ))}
    </ul>
  </div>
);

// Page container
const Page = ({ children, screen, title, summary }) => {
  // 自動朗讀頁面標題（聽覺優先模式 / tts_default flag 開啟時）
  usePageAutoAnnounce(title || screen, summary);
  return (
    <main data-screen-label={screen} style={{ maxWidth: 1280, margin: "0 auto", padding: "32px 24px 48px" }}>
      {children}
    </main>
  );
};

// Section header
const SectionHeader = ({ eyebrow, title, desc, action }) => (
  <div style={{ display: "flex", alignItems: "flex-end", justifyContent: "space-between", marginBottom: 24, gap: 24 }}>
    <div>
      {eyebrow && (
        <div style={{
          fontSize: "var(--fs-xs)", fontWeight: 700, color: "var(--accent-600)",
          letterSpacing: "0.14em", textTransform: "uppercase", marginBottom: 8,
        }}>{eyebrow}</div>
      )}
      <h2 style={{ margin: 0, fontSize: "var(--fs-2xl)", fontWeight: 800, letterSpacing: "-0.02em", color: "var(--ink)" }}>
        {title}
      </h2>
      {desc && <p style={{ margin: "6px 0 0", color: "var(--ink-soft)", fontSize: "var(--fs-base)" }}>{desc}</p>}
    </div>
    {action}
  </div>
);

Object.assign(window, {
  Icon, DisabilityBadge, FeatureBadge, Button, Tag, Card, IconBtn, TopNav, Footer, Page, SectionHeader, FooterCol,
});
