// Header.jsx — top-level page nav (工作台 / 學院 / 簡報) + sub-tabs

// Neutral placeholder avatar for the not-signed-in state
function GuestAvatar({ size = 28 }) {
  return (
    <div style={{
      width: size, height: size, borderRadius: "50%",
      background: "var(--fill-secondary)",
      color: "var(--label-secondary)",
      display: "inline-flex", alignItems: "center", justifyContent: "center",
      flexShrink: 0,
    }}>
      <svg width={Math.round(size * 0.56)} height={Math.round(size * 0.56)} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round">
        <circle cx="12" cy="8" r="4"/>
        <path d="M4 20c0-4 3.6-6 8-6s8 2 8 6"/>
      </svg>
    </div>
  );
}

// ── 手機版導覽：底部 5 格分頁列、＋快速新增、「我」頁面 ──
// 桌面版不顯示底部列（CSS 控制），仍用 Header 上方的文字導覽。
// 刻意放在 Header.jsx 而不是獨立檔案：舊版快取的 index.html 不會載入新檔，會讓 Header 找不到這些函式。

// 底部分頁 → 對應的工作台子分頁。Header 也用這張表決定手機上要顯示哪幾個子分頁。
const MOBILE_TAB_GROUPS = {
  home:  ["overview"],
  tasks: ["worklog"],
  parts: ["parts", "specs"],
  me:    ["people", "plans", "resources"],
};

// 目前畫面屬於哪一個底部分頁
function mobileGroupOf(page, subTab) {
  if (page !== "dashboard") return "me";           // 我 / 學院 / 簡報 / 數位雙生
  for (const g of Object.keys(MOBILE_TAB_GROUPS)) {
    if (MOBILE_TAB_GROUPS[g].includes(subTab)) return g;
  }
  return "home";
}

function BottomTabBar({ page, subTab, onNavigate, onQuickAdd }) {
  const [sheetOpen, setSheetOpen] = React.useState(false);
  const group = mobileGroupOf(page, subTab);

  const tabs = [
    { id: "home",  label: "首頁", icon: "target",
      go: () => onNavigate("dashboard", "overview") },
    { id: "tasks", label: "任務", icon: "calendar",
      go: () => onNavigate("dashboard", "worklog") },
    { id: "add" },
    { id: "parts", label: "零件", icon: "factory",
      go: () => onNavigate("dashboard", group === "parts" ? subTab : "parts") },
    { id: "me",    label: "我",   icon: "user",
      go: () => onNavigate("me") },
  ];

  const pick = (kind) => { setSheetOpen(false); onQuickAdd(kind); };

  return (
    <>
      <nav className="bottom-tab-bar" aria-label="主要導覽">
        {tabs.map(tab => {
          if (tab.id === "add") {
            return (
              <button key="add" className="bottom-tab-add" aria-label="新增"
                aria-haspopup="dialog" aria-expanded={sheetOpen}
                onClick={() => setSheetOpen(true)}>
                <span className="bottom-tab-add-circle"><UIIcon kind="plus" size={22} /></span>
              </button>
            );
          }
          const active = group === tab.id;
          return (
            <button key={tab.id}
              className={`bottom-tab-btn${active ? " active" : ""}`}
              onClick={tab.go}
              aria-current={active ? "page" : undefined}>
              <span className="bottom-tab-icon"><UIIcon kind={tab.icon} size={20} /></span>
              <span>{tab.label}</span>
            </button>
          );
        })}
      </nav>

      {sheetOpen && (
        <div className="qa-back" onClick={() => setSheetOpen(false)}>
          <div className="qa-sheet" role="dialog" aria-label="新增" onClick={e => e.stopPropagation()}>
            <div className="qa-title">新增</div>
            {[
              { kind: "task", label: "任務",     hint: "一件待辦事項",       icon: "calendar" },
              { kind: "plan", label: "計畫",     hint: "提出一份設計提案",   icon: "wrench" },
              { kind: "part", label: "零件",     hint: "加入採購／供應商項目", icon: "factory" },
            ].map(o => (
              <button key={o.kind} className="qa-row" onClick={() => pick(o.kind)}>
                <span className="qa-row-icon"><UIIcon kind={o.icon} size={18} /></span>
                <span className="qa-row-text">
                  <span className="qa-row-label">{o.label}</span>
                  <span className="qa-row-hint">{o.hint}</span>
                </span>
                <UIIcon kind="chevron-right" size={16} />
              </button>
            ))}
            <button className="qa-cancel" onClick={() => setSheetOpen(false)}>取消</button>
          </div>
        </div>
      )}
    </>
  );
}

// 「我」頁面：人員、學院、簡報的入口＋外觀設定
function MePage({ peopleCount, onNavigate, appearance, onAppearanceChange, theme, onThemeChange }) {
  const links = [
    { label: "人員", hint: `${peopleCount} 位成員`, icon: "users",  go: () => onNavigate("dashboard", "people") },
    { label: "資料", hint: "內部提案、外部資源",     icon: "book",   go: () => onNavigate("dashboard", "plans") },
    { label: "學院", hint: "分級課程",              icon: "book",   go: () => onNavigate("academy") },
    { label: "簡報", hint: "招募與車隊介紹",        icon: "layers", go: () => onNavigate("deck") },
  ];
  const Segment = ({ options, value, onChange }) => (
    <div className="me-segment" role="radiogroup">
      {options.map(o => (
        <button key={o.id} role="radio" aria-checked={value === o.id}
          className={`me-segment-btn${value === o.id ? " is-active" : ""}`}
          onClick={() => onChange?.(o.id)}>{o.label}</button>
      ))}
    </div>
  );
  return (
    <div className="me-page">
      <h1 className="me-title">我</h1>

      <div className="me-card">
        {links.map(l => (
          <button key={l.label} className="me-row" onClick={l.go}>
            <span className="me-row-icon"><UIIcon kind={l.icon} size={18} /></span>
            <span className="me-row-text">
              <span className="me-row-label">{l.label}</span>
              <span className="me-row-hint">{l.hint}</span>
            </span>
            <UIIcon kind="chevron-right" size={16} />
          </button>
        ))}
      </div>

      <div className="me-section-label">外觀</div>
      <Segment value={appearance} onChange={onAppearanceChange}
        options={[{ id: "light", label: "淺色" }, { id: "dark", label: "深色" }, { id: "auto", label: "自動" }]} />

      <div className="me-section-label">設計風格</div>
      <Segment value={theme} onChange={onThemeChange}
        options={[{ id: "glass", label: "Glass" }, { id: "flat", label: "Flat" }, { id: "editorial", label: "Editorial" }]} />
    </div>
  );
}

window.MOBILE_TAB_GROUPS = MOBILE_TAB_GROUPS;
window.mobileGroupOf = mobileGroupOf;
window.BottomTabBar = BottomTabBar;
window.MePage = MePage;

function Header({ page, onPageChange, onNavigate, onQuickAdd, subTab, onSubTabChange, dashTabs, peopleCount, appearance = "auto", onAppearanceChange, theme = "glass", onThemeChange }) {
  const [settingsOpen, setSettingsOpen] = React.useState(false);
  const menuWrapRef = React.useRef(null);
  const wrapperRef = React.useRef(null);
  const [hdrHidden, setHdrHidden] = React.useState(false);
  const subHidden = hdrHidden;
  // 手機：子分頁列只顯示目前底部分頁所屬的那幾個
  const mobileGroup = mobileGroupOf(page, subTab);
  const groupTabs = MOBILE_TAB_GROUPS[mobileGroup] || [];
  // 手機這一組實際看得到幾個分頁（合併分頁算一個）
  const groupTabCount = (dashTabs || []).filter(t => (t.members || [t.id]).some(id => groupTabs.includes(id))).length;
  const lastScrollY = React.useRef(0);

  // ── Tab 切換時：重設顯示、捲回頂部 ──
  React.useEffect(() => {
    setHdrHidden(false);
    lastScrollY.current = 0;
    const el = document.querySelector('.main-content');
    if (el) el.scrollTop = 0;
  }, [page, subTab]);

  // ── Scroll-hide：捲下隱藏主列，捲回頂部顯示 ──
  React.useEffect(() => {
    const el = document.querySelector('.main-content');
    if (!el) return;
    const onScroll = () => {
      const y = el.scrollTop;
      const delta = y - lastScrollY.current;
      if (delta > 6 && y > 60) setHdrHidden(true);
      else if (delta < -6 || y < 10) setHdrHidden(false);
      lastScrollY.current = y;
    };
    el.addEventListener('scroll', onScroll, { passive: true });
    return () => el.removeEventListener('scroll', onScroll);
  }, []);

  // ── 把 header 實際高度寫成 CSS 變數，讓 main-content 計算 padding-top ──
  // 只量一次會量到還沒排好版的高度（0），全螢幕嵌入頁（車架設計）上緣就被 header 蓋住，所以持續量
  React.useLayoutEffect(() => {
    const el = wrapperRef.current;
    if (!el) return;
    const set = () => document.documentElement.style.setProperty('--hdr-total-h', el.getBoundingClientRect().height + 'px');
    set();
    const ro = new ResizeObserver(set);
    ro.observe(el);
    return () => ro.disconnect();
  }, [page, subTab, dashTabs]);

  React.useEffect(() => {
    if (!settingsOpen) return;
    const onDown = (e) => {
      if (menuWrapRef.current && !menuWrapRef.current.contains(e.target)) {
        setSettingsOpen(false);
      }
    };
    const onEsc = (e) => { if (e.key === "Escape") setSettingsOpen(false); };
    document.addEventListener("mousedown", onDown);
    document.addEventListener("keydown", onEsc);
    return () => {
      document.removeEventListener("mousedown", onDown);
      document.removeEventListener("keydown", onEsc);
    };
  }, [settingsOpen]);
  // 工作台分頁按鈕：桌面放在隊名右邊（inline），手機放在下面那一列
  const tabButtons = (inline) => dashTabs.map((t) =>
            { const ids = t.members || [t.id], on = ids.includes(subTab); return (
            <button key={t.id} onClick={() => { if (!on) onSubTabChange(ids[0]); }}
            className={"hdr-sub-tab" + (ids.some(id => groupTabs.includes(id)) ? "" : " hdr-sub-tab--offgroup") + (on ? " is-active" : "")}
            style={{
              ...hdrStyles.subTab, ...(inline ? hdrStyles.inlineTab : null),
              color: on ? "var(--label-primary)" : "var(--label-secondary)",
              fontWeight: on ? 600 : 400,
              borderBottomColor: on ? "var(--blue)" : "transparent"
            }}>
                  {t.en ? <span className="sub-tab-en" title={t.label}>{t.en}</span>
                        : <><UIIcon kind={t.icon} size={13} /><span className="sub-tab-label">{t.label}</span></>}
                  {t.count !== undefined && <span className="sub-tab-count" style={{
                fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--muted)",
                marginLeft: 2
              }}>{t.count}</span>}
                </button>); }
            );
  return (
    <>
    <div ref={wrapperRef} className={`hdr-wrapper${hdrHidden ? " hdr--hidden" : ""}${page !== "dashboard" || groupTabCount < 2 ? " hdr-wrapper--bare" : ""}`} style={hdrStyles.bar}>
      <header style={{ ...hdrStyles.inner, fontFamily: "-apple-system" }}>
        <div style={hdrStyles.left} className="hdr-left">
          <div style={{ ...hdrStyles.logoBox, cursor: "pointer" }} className="hdr-logo-box" title="回首頁"
            onClick={() => onNavigate?.("dashboard", "overview")}>
            <img src="public/logo/nkust-logo.png" alt="NKUST" style={hdrStyles.logoImg} className="hdr-logo-img" />
          </div>
          <span style={hdrStyles.wordmark} className="hdr-wordmark">高科大賽車隊</span>
        </div>
        {page === "dashboard" && dashTabs &&
          <nav className="hdr-inline-tabs" aria-label="工作台分頁">{tabButtons(true)}</nav>}
        <div style={hdrStyles.actions}>



          {/* Avatar — doubles as the account / settings menu trigger (guest state) */}
          <div ref={menuWrapRef} className="hdr-avatar-wrap" style={{ position: "relative" }}>
            <button style={{ ...hdrStyles.avatarBtn, boxShadow: settingsOpen ? "0 0 0 2px var(--blue)" : "none" }}
              title="帳號與設定" onClick={() => setSettingsOpen(v => !v)}>
              <GuestAvatar size={28} />
            </button>

            {settingsOpen && (
              <div style={hdrStyles.menu}>
                {/* 人員名單（取代原本的「未登入」列） */}
                <button style={{ ...hdrStyles.menuProfile, width: "100%", border: "none", background: "transparent", cursor: "pointer", textAlign: "left" }}
                  onMouseEnter={e => e.currentTarget.style.background = "var(--fill-tertiary)"}
                  onMouseLeave={e => e.currentTarget.style.background = "transparent"}
                  onClick={() => { setSettingsOpen(false); onNavigate?.("dashboard", "people"); }}
                  title="人員名單">
                  <span style={{ width: 38, height: 38, borderRadius: "50%", background: "var(--fill-tertiary)", display: "grid", placeItems: "center", color: "var(--label-primary)", flex: "none" }}>
                    <UIIcon kind="users" size={18} />
                  </span>
                  <div style={{ minWidth: 0, flex: 1 }}>
                    <div style={hdrStyles.menuName}>人員名單</div>
                    <div style={hdrStyles.menuRole}>{peopleCount != null ? `${peopleCount} 位成員` : "車隊成員"}</div>
                  </div>
                  <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="var(--label-tertiary)" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><polyline points="9 18 15 12 9 6"/></svg>
                </button>

                <div style={hdrStyles.menuDivider}/>

                <div style={hdrStyles.menuSectionLabel}>頁面</div>
                {[
                  { id: "dashboard", label: "工作台", icon: "target" },
                  { id: "academy",   label: "學院",   icon: "book" },
                  { id: "deck",      label: "簡報",   icon: "layers" },
                ].map(p => {
                  const active = page === p.id;
                  return (
                    <button key={p.id} onClick={() => { setSettingsOpen(false); onPageChange(p.id); }}
                      style={hdrStyles.menuRow}
                      onMouseEnter={e => e.currentTarget.style.background = "var(--fill-tertiary)"}
                      onMouseLeave={e => e.currentTarget.style.background = "transparent"}>
                      <span style={hdrStyles.menuRowIcon}><UIIcon kind={p.icon} size={17} /></span>
                      <span style={{ flex: 1, textAlign: "left", fontSize: 14, fontWeight: active ? 600 : 400, color: "var(--label-primary)" }}>{p.label}</span>
                      {active && (
                        <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="var(--blue)" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
                          <polyline points="20 6 9 17 4 12"/>
                        </svg>
                      )}
                    </button>
                  );
                })}

                <div style={hdrStyles.menuDivider}/>

                <div style={hdrStyles.menuSectionLabel}>外觀</div>
                {[
                  { id: "light", label: "淺色" },
                  { id: "dark",  label: "深色" },
                  { id: "auto",  label: "自動" },
                ].map(opt => {
                  const active = appearance === opt.id;
                  return (
                    <button key={opt.id} onClick={() => onAppearanceChange?.(opt.id)}
                      style={hdrStyles.menuRow}
                      onMouseEnter={e => e.currentTarget.style.background = "var(--fill-tertiary)"}
                      onMouseLeave={e => e.currentTarget.style.background = "transparent"}>
                      <span style={hdrStyles.menuRowIcon}>
                        <svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">
                          {opt.id === "light" && <><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></>}
                          {opt.id === "dark" && <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>}
                          {opt.id === "auto" && <><circle cx="12" cy="12" r="9"/><path d="M12 3a9 9 0 0 0 0 18z" fill="currentColor" stroke="none"/></>}
                        </svg>
                      </span>
                      <span style={{ flex: 1, textAlign: "left", fontSize: 14, fontWeight: 400, color: "var(--label-primary)" }}>{opt.label}</span>
                      {active && (
                        <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="var(--blue)" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
                          <polyline points="20 6 9 17 4 12"/>
                        </svg>
                      )}
                    </button>
                  );
                })}

                <div style={hdrStyles.menuDivider}/>

                <div style={hdrStyles.menuSectionLabel}>設計風格</div>
                {[
                  { id: "glass", label: "Glass" },
                  { id: "flat",  label: "Flat" },
                  { id: "editorial", label: "Editorial" },
                ].map(opt => {
                  const active = theme === opt.id;
                  return (
                    <button key={opt.id} onClick={() => onThemeChange?.(opt.id)}
                      style={hdrStyles.menuRow}
                      onMouseEnter={e => e.currentTarget.style.background = "var(--fill-tertiary)"}
                      onMouseLeave={e => e.currentTarget.style.background = "transparent"}>
                      <span style={hdrStyles.menuRowIcon}>
                        <svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">
                          {opt.id === "glass" && <><polygon points="12 2 2 7 12 12 22 7 12 2"/><polyline points="2 17 12 22 22 17"/><polyline points="2 12 12 17 22 12"/></>}
                          {opt.id === "flat" && <rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>}
                          {opt.id === "editorial" && <><path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"/><path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"/></>}
                        </svg>
                      </span>
                      <span style={{ flex: 1, textAlign: "left", fontSize: 14, fontWeight: 400, color: "var(--label-primary)" }}>{opt.label}</span>
                      {active && (
                        <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="var(--blue)" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round">
                          <polyline points="20 6 9 17 4 12"/>
                        </svg>
                      )}
                    </button>
                  );
                })}
              </div>
            )}
          </div>
        </div>
      </header>
      {page === "dashboard" && dashTabs &&
      <div className={(hdrHidden ? "hdr-subbar hdr-sub--hidden" : "hdr-subbar") + (groupTabCount < 2 ? " hdr-subbar--solo" : "")} style={hdrStyles.subBar}>
          <div style={{ ...hdrStyles.subInner, opacity: "1" }}>
            <nav className="hdr-sub-nav" style={{ ...hdrStyles.subNav }}>
              {tabButtons(false)}
            </nav>
          </div>
        </div>
      }
    </div>
    {/* Bottom Tab Bar — 在 backdrop-filter div 外面，確保 position:fixed 正常作用 */}
    <BottomTabBar page={page} subTab={subTab} onNavigate={onNavigate} onQuickAdd={onQuickAdd} />
  </>);

}

const hdrStyles = {
  bar: {
    position: "sticky", top: 0, zIndex: 100,
    background: "var(--header-bg)",
    backdropFilter: "saturate(180%) blur(28px)",
    WebkitBackdropFilter: "saturate(180%) blur(28px)",
    borderBottom: "0.5px solid var(--header-border)",
    boxShadow: "var(--header-shadow)"
  },
  inner: {
    display: "flex", alignItems: "center", height: 52,
    maxWidth: 1440, margin: "0 auto", padding: "0 var(--hdr-pad, 40px)", gap: 0
  },
  left: { display: "flex", alignItems: "center", gap: 10, flexShrink: 0 },
  logoBox: {
    width: 28, height: 28, overflow: "hidden",
    display: "flex", alignItems: "center",
    flexShrink: 0
  },
  logoImg: {
    height: 28, width: "auto",
    objectFit: "cover", objectPosition: "left center",
    flexShrink: 0
  },
  mark: {
    width: 24, height: 24, borderRadius: 7, background: "var(--ink)",
    display: "flex", alignItems: "center", justifyContent: "center",
    color: "#fff", fontFamily: "var(--font-mono)",
    fontSize: 9, fontWeight: 700, letterSpacing: "-0.4px"
  },
  wordmark: { fontSize: 14, fontWeight: 600, letterSpacing: "-0.014em", color: "var(--ink)" },
  sep: { color: "var(--rule)", margin: "0 4px" },
  season: {
    fontFamily: "var(--font-mono)", fontSize: 11, color: "var(--muted)",
    letterSpacing: "0.04em"
  },
  pageNav: { display: "flex", alignItems: "center", marginLeft: "auto", gap: 4 },
  pageTab: {
    padding: "7px var(--page-tab-pad, 16px)",
    background: "transparent", border: "none", borderRadius: 980,
    fontSize: "var(--page-tab-fs, 13px)", letterSpacing: "-0.005em", cursor: "pointer",
    whiteSpace: "nowrap", transition: "all .15s",
    fontWeight: 500, fontFamily: "inherit"
  },
  actions: { display: "flex", alignItems: "center", gap: 6, flexShrink: 0, marginLeft: "auto" },
  hdrBtn: {
    width: 32, height: 32,            /* 32px visual, 44pt tappable area via padding */
    minWidth: 44, minHeight: 44,      /* HIG: 44pt minimum touch target */
    borderRadius: "var(--radius-sm)", background: "transparent",
    border: "none", color: "var(--label-secondary)", cursor: "pointer",
    display: "flex", alignItems: "center", justifyContent: "center",
    transition: "background .15s, transform .1s",
    marginInline: -6,                 /* compensate extra touch area */
  },
  avatarBtn: {
    width: 28, height: 28, padding: 0, border: "none", background: "transparent",
    borderRadius: "50%", cursor: "pointer", flexShrink: 0,
    display: "flex", alignItems: "center", justifyContent: "center",
    transition: "box-shadow .15s",
  },
  /* ── Apple-style account / settings menu ── */
  menu: {
    position: "absolute", top: "calc(100% + 10px)", right: 0, zIndex: 200,
    background: "var(--bg-secondary)",
    border: "0.5px solid var(--separator)",
    borderRadius: 14,
    boxShadow: "var(--shadow-4)",
    padding: 7, minWidth: 248,
    backdropFilter: "blur(40px) saturate(180%)",
    WebkitBackdropFilter: "blur(40px) saturate(180%)",
    transformOrigin: "top right",
    animation: "modal-pop .22s var(--ease-out)",
  },
  menuProfile: {
    display: "flex", alignItems: "center", gap: 11,
    padding: "8px 10px 10px",
  },
  menuName: {
    fontSize: 15, fontWeight: 600, color: "var(--label-primary)",
    letterSpacing: "-0.01em", lineHeight: 1.2,
    overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap",
  },
  menuRole: {
    fontSize: 12, color: "var(--label-secondary)", lineHeight: 1.3, marginTop: 2,
    overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap",
  },
  menuDivider: { height: "0.5px", background: "var(--separator)", margin: "3px 4px 5px" },
  menuSectionLabel: {
    fontSize: 11, fontWeight: 600, color: "var(--label-tertiary)",
    letterSpacing: "0.02em", padding: "4px 12px 6px",
  },
  menuRow: {
    display: "flex", alignItems: "center", gap: 11, width: "100%",
    padding: "8px 12px", border: "none", background: "transparent",
    borderRadius: 8, cursor: "pointer", fontFamily: "inherit",
    transition: "background .12s",
  },
  menuRowIcon: {
    width: 22, display: "flex", alignItems: "center", justifyContent: "center",
    color: "var(--label-secondary)", flexShrink: 0,
  },
  subBar: {
    background: "transparent"
  },
  subInner: { maxWidth: 1440, margin: "0 auto", padding: "0 var(--hdr-pad, 40px)" },
  subNav: { display: "flex", gap: 0, alignItems: "center" },
  inlineTab: { height: 52, padding: "0 13px", gap: 6, borderTop: "2px solid transparent" },
  subTab: {
    display: "flex", alignItems: "center", gap: 7,
    padding: "10px var(--page-tab-pad, 16px)", height: 42,
    background: "transparent", border: "none",
    borderBottom: "2px solid transparent",
    fontSize: "calc(var(--page-tab-fs, 13px) - 0.5px)", cursor: "pointer", letterSpacing: "-0.005em",
    transition: "color .15s, border-color .15s, font-weight .15s",
    fontFamily: "inherit"
  }
};

window.Header = Header;