/* HMU HR Portal — 本文セクション */
const { useState: useS, useMemo } = React;
const HRD = window.HMU_HR;
const { CAT_COLORS, STATUS, fmtDate } = HRD;

const statusStyle = (s) => ({
  done: { bg:'var(--green-tint2)', fg:'var(--green-deep)' }, now: { bg:'var(--green)', fg:'#fff' }, next: { bg:'#fff', fg:'var(--sub)' },
}[s] || { bg:'#fff', fg:'var(--sub)' });

/* ── インフォメーション通知（ポップアップ）── */
function NoticeModal({ notice, onClose }) {
  React.useEffect(() => {
    const k = (e) => { if (e.key === 'Escape') onClose(); };
    window.addEventListener('keydown', k);
    return () => window.removeEventListener('keydown', k);
  }, [onClose]);
  if (!notice) return null;
  return (
    <div onClick={onClose} style={{ position:'fixed', inset:0, zIndex:200, background:'rgba(11,21,18,.55)', backdropFilter:'blur(4px)', display:'flex', alignItems:'flex-start', justifyContent:'center', padding:'clamp(16px,4vh,56px) 16px', overflowY:'auto' }}>
      <article onClick={(e)=>e.stopPropagation()} style={{ background:'#fff', borderRadius:20, maxWidth:800, width:'100%', padding:'clamp(26px,3.4vw,48px)', boxShadow:'0 30px 80px rgba(11,21,18,.3)', position:'relative' }}>
        <button onClick={onClose} aria-label="閉じる" style={{ position:'absolute', top:16, right:16, width:34, height:34, borderRadius:99, border:'1.5px solid var(--line)', background:'#fff', fontSize:15, cursor:'pointer', color:'var(--sub)', fontFamily:'inherit', lineHeight:1 }}>×</button>
        <div style={{ display:'flex', gap:12, alignItems:'baseline', flexWrap:'wrap', marginBottom:16 }}>
          <span style={{ fontSize:10.5, fontWeight:800, color:'var(--green)', background:'var(--green-tint)', padding:'4px 10px', borderRadius:99 }}>{notice.label}</span>
          <span className="num" style={{ fontSize:11.5, fontWeight:700, color:'var(--faint)' }}>{notice.date}</span>
        </div>
        <h3 className="disp" style={{ fontSize:'clamp(17px,1.9vw,23px)', fontWeight:900, lineHeight:1.6, margin:'0 0 20px', paddingRight:30, textWrap:'pretty' }}>{notice.title}</h3>
        <div style={{ display:'flex', justifyContent:'space-between', gap:16, flexWrap:'wrap', paddingBottom:18, marginBottom:22, borderBottom:'1px solid var(--line)', fontSize:12.5, fontWeight:700, color:'var(--sub)' }}>
          <span>{notice.to}</span><span>{notice.from}</span>
        </div>
        <div style={{ display:'flex', flexDirection:'column', gap:18 }}>
          {(notice.paragraphs || []).map((p,i) => (
            <p key={i} style={{ fontSize:13.5, lineHeight:2.1, color:'var(--sub)', margin:0, textWrap:'pretty' }}>{p}</p>
          ))}
        </div>
        <p style={{ fontSize:11.5, color:'var(--faint)', lineHeight:1.9, margin:'22px 0 0', paddingTop:18, borderTop:'1px solid var(--line)' }}>{notice.note}</p>
        <button onClick={onClose} className="btn-dark" style={{ marginTop:20, padding:'12px 26px', borderRadius:99, border:'none', fontSize:13, fontWeight:800, cursor:'pointer', fontFamily:'inherit' }}>閉じる</button>
      </article>
    </div>
  );
}

/* ── インフォメーション通知（理事長名義の文面）── */
function NoticeLetter({ notice, docUrl }) {
  const [open, setOpen] = useS(false);
  if (!notice || notice.show === false) return null;
  const paras = notice.paragraphs || [];
  const shown = open ? paras : paras.slice(0, 1);
  return (
    <section style={{ background:'var(--paper2)', borderTop:'1px solid var(--line)', borderBottom:'1px solid var(--line)' }}>
      <div className="wrap" style={{ padding:'clamp(52px,6vw,84px) 26px' }}>
        <SectionHead id="notice" en="INFORMATION" ja="インフォメーション通知全文" note="全教職員へ発信された通知文を、このページでもお読みいただけます。" />
        <article className="card" style={{ padding:'clamp(28px,3.4vw,52px)', maxWidth:900 }}>
          <div style={{ display:'flex', gap:12, alignItems:'baseline', flexWrap:'wrap', marginBottom:18 }}>
            <span style={{ fontSize:10.5, fontWeight:800, color:'var(--green)', background:'var(--green-tint)', padding:'4px 10px', borderRadius:99 }}>{notice.label}</span>
            <span className="num" style={{ fontSize:11.5, fontWeight:700, color:'var(--faint)' }}>{notice.date}</span>
          </div>
          <h3 className="disp" style={{ fontSize:'clamp(17px,1.9vw,24px)', fontWeight:900, lineHeight:1.6, margin:'0 0 22px', textWrap:'pretty' }}>{notice.title}</h3>
          <div style={{ display:'flex', justifyContent:'space-between', gap:16, flexWrap:'wrap', paddingBottom:20, marginBottom:24, borderBottom:'1px solid var(--line)', fontSize:12.5, fontWeight:700, color:'var(--sub)' }}>
            <span>{notice.to}</span><span>{notice.from}</span>
          </div>
          <div style={{ display:'flex', flexDirection:'column', gap:18 }}>
            {shown.map((p,i) => (
              <p key={i} style={{ fontSize:13.5, lineHeight:2.1, color:'var(--sub)', margin:0, textWrap:'pretty' }}>{p}</p>
            ))}
          </div>
          {paras.length > 1 ? (
            <button onClick={()=>setOpen(!open)} style={{ marginTop:22, padding:'11px 22px', borderRadius:99, border:'1.5px solid var(--ink)', background:'#fff', fontSize:12.5, fontWeight:800, cursor:'pointer', fontFamily:'inherit', color:'var(--ink)' }}>
              {open ? '本文を閉じる' : '全文を読む（あと' + (paras.length-1) + '段落）'}
            </button>
          ) : null}
          {open ? (
            <div style={{ marginTop:26, paddingTop:22, borderTop:'1px solid var(--line)', display:'flex', gap:16, flexWrap:'wrap', alignItems:'center' }}>
              <p style={{ fontSize:12, color:'var(--faint)', lineHeight:1.9, margin:0, flex:1, minWidth:240 }}>{notice.note}</p>
              {docUrl ? <a href={docUrl} target="_blank" rel="noopener" style={{ fontSize:12.5, fontWeight:800, whiteSpace:'nowrap' }}>PDFで見る →</a> : null}
            </div>
          ) : null}
        </article>
      </div>
    </section>
  );
}

/* ── 先行施策 ＋ 工程表 ── */
function Initiatives({ initiatives, roadmap }) {
  const allI = HRD.pub(initiatives), allR = HRD.pub(roadmap);
  const years = Array.from(new Set([...allI, ...allR].map(x => x.year).filter(Boolean))).sort((a,b)=>a-b);
  const [year, setYear] = useS(years[0] || 2026);
  const its = allI.filter(x => !x.year || x.year === year);
  const road = allR.filter(x => !x.year || x.year === year);
  return (
    <section className="wrap" style={{ padding:'clamp(60px,7vw,92px) 26px' }}>
      <SectionHead id="roadmap" en={'ACTIONS ' + year} ja={year + '年度に着手する施策'} note="「日常」を支える福利厚生の拡充と、管理職の意識改革から着手します。詳細は導入時に改めて通知します。"
        action={null} />
      {years.length > 1 ? (
        <div style={{ display:'flex', gap:7, flexWrap:'wrap', marginBottom:18 }}>
          {years.map(y => <button key={y} onClick={()=>setYear(y)} className={'chip'+(year===y?' on':'')}>{y}年度</button>)}
        </div>
      ) : null}
      <div className="init-grid" style={{ display:'grid', gridTemplateColumns:'repeat(3,1fr)', gap:14, marginBottom:'clamp(36px,4vw,56px)' }}>
        {its.map((it, i) => {
          const st = statusStyle(it.status);
          return (
            <article key={it.id} className="card hoverable" style={{ padding:'clamp(22px,2.2vw,30px)', display:'flex', flexDirection:'column', gap:12 }}>
              <div style={{ display:'flex', alignItems:'center', gap:8 }}>
                <span style={{ fontSize:10.5, fontWeight:800, color:CAT_COLORS[it.tag]||'var(--green)', background:(CAT_COLORS[it.tag]||'#1B6B54')+'14', padding:'4px 10px', borderRadius:99 }}>{it.tag}</span>
                <span className="num" style={{ fontSize:10, fontWeight:800, letterSpacing:'.08em', background:st.bg, color:st.fg, padding:'4px 10px', borderRadius:99, border:it.status==='next'?'1px solid var(--line)':'none' }}>{STATUS[it.status]}</span>
                <span className="num" style={{ marginLeft:'auto', fontSize:30, fontWeight:800, color:'var(--line)', lineHeight:1 }}>0{i+1}</span>
              </div>
              <h3 className="disp" style={{ fontSize:'clamp(16px,1.5vw,19px)', fontWeight:900, lineHeight:1.55, margin:0 }}>{it.title}</h3>
              <div style={{ fontSize:12, fontWeight:700, color:'var(--green)' }}>{it.when}</div>
              <p style={{ fontSize:13, color:'var(--sub)', lineHeight:1.9, margin:0, textWrap:'pretty' }}>{it.desc}</p>
            </article>
          );
        })}
      </div>
      <div className="card" style={{ padding:'clamp(24px,2.5vw,34px)' }}>
        <div style={{ display:'flex', alignItems:'baseline', gap:12, marginBottom:22 }}>
          <h3 className="disp" style={{ fontSize:16, fontWeight:900, margin:0 }}>{year}年度 実施スケジュール</h3>
          <span className="num" style={{ fontSize:10, fontWeight:800, letterSpacing:'.14em', color:'var(--faint)' }}>ROADMAP</span>
        </div>
        <ol className="road" style={{ listStyle:'none', margin:0, padding:0, display:'grid', gridTemplateColumns:'repeat(4,1fr)', gap:'20px 0' }}>
          {road.map((r) => {
            const st = statusStyle(r.status);
            return (
              <li key={r.id} style={{ paddingRight:18, borderTop:`3px solid ${r.status==='next'?'var(--line)':'var(--green)'}`, paddingTop:14 }}>
                <div className="num" style={{ fontSize:15, fontWeight:800, marginBottom:8, color: r.status==='next'?'var(--faint)':'var(--ink)' }}>{r.when}</div>
                <div style={{ fontSize:12.5, fontWeight:600, lineHeight:1.7, color:'var(--sub)', marginBottom:9, textWrap:'pretty' }}>{r.label}</div>
                <span className="num" style={{ fontSize:9.5, fontWeight:800, letterSpacing:'.08em', background:st.bg, color:st.fg, padding:'3px 9px', borderRadius:99, border:r.status==='next'?'1px solid var(--line)':'none' }}>{STATUS[r.status]}</span>
              </li>
            );
          })}
        </ol>
      </div>
    </section>
  );
}

/* ── 標語公募 ── */
function SloganCall({ hero }) {
  const c = hero.campaign;
  const decided = hero.mode === 'slogan';
  const formUrl = c.formUrl || '#';
  return (
    <section id="slogan" style={{ background:'var(--green-tint)', color:'var(--ink)', borderTop:'1px solid var(--line)', borderBottom:'1px solid var(--line)', scrollMarginTop:70 }}>
      <div className="wrap slogan-grid" style={{ padding:'clamp(56px,6.5vw,88px) 26px', display:'grid', gridTemplateColumns:'1fr .85fr', gap:'clamp(32px,4.5vw,64px)', alignItems:'start' }}>
        <div>
          <div className="num" style={{ fontSize:10.5, fontWeight:800, letterSpacing:'.18em', color:'var(--green)', marginBottom:14 }}>SLOGAN OPEN CALL</div>
          <h2 className="disp" style={{ fontSize:'clamp(23px,2.8vw,34px)', fontWeight:900, lineHeight:1.4, margin:'0 0 18px', textWrap:'pretty' }}>
            {decided ? '標語は教職員の公募により決定しました' : '標語（キャッチフレーズ）を公募します'}
          </h2>
          <p style={{ fontSize:13.5, color:'var(--sub)', lineHeight:2, margin:'0 0 28px', maxWidth:560, textWrap:'pretty' }}>
            {decided ? `決定した標語「${hero.slogan.text}」を軸に、これからの施策を進めていきます。ご応募いただいた皆さまに感謝申し上げます。` : '目指す組織風土・職場環境を、より深く浸透させていくための標語を策定します。言葉は現場から。職種・立場・雇用形態を問わず、すべての教職員が応募できます。'}
          </p>
          <dl className="slogan-dl" style={{ margin:0, display:'grid', gridTemplateColumns:'96px 1fr', gap:'0', fontSize:13 }}>
            {[['募集期間', c.period],['決定・発表', c.decide],['応募条件', c.note],['応募方法', 'Googleフォームから送信（学内アカウントでアクセスできます）'],['選考', '人事部で一次選考のうえ、常務会にて決定']].map(([k,val]) => (
              <React.Fragment key={k}>
                <dt style={{ padding:'13px 0', borderTop:'1px solid rgba(27,107,84,.2)', fontWeight:800, color:'var(--green)', fontSize:12 }}>{k}</dt>
                <dd style={{ padding:'13px 0', borderTop:'1px solid rgba(27,107,84,.2)', margin:0, color:'var(--ink)', lineHeight:1.7 }}>{val}</dd>
              </React.Fragment>
            ))}
          </dl>
        </div>
        <div style={{ background:'#fff', borderRadius:20, padding:'clamp(26px,2.8vw,36px)', border:'1px solid var(--line)', boxShadow:'0 12px 30px rgba(11,21,18,.05)', display:'flex', flexDirection:'column', gap:16 }}>
          <div className="num" style={{ fontSize:10, fontWeight:800, letterSpacing:'.16em', color:'var(--green)' }}>GOOGLE FORM</div>
          <div className="disp" style={{ fontSize:'clamp(17px,1.7vw,21px)', fontWeight:900, lineHeight:1.6 }}>
            {decided ? '応募の受付は終了しました' : '応募はGoogleフォームから'}
          </div>
          <p style={{ fontSize:12.5, color:'var(--sub)', lineHeight:1.95, margin:0, textWrap:'pretty' }}>
            {decided ? 'たくさんのご応募をありがとうございました。決定した標語を軸に、これからの施策を進めていきます。' : '入力項目は「標語」「込めた想い（任意）」「所属・氏名（任意）」の3つだけ。1〜2分で送信できます。'}
          </p>
          {decided ? null : (
            <ul style={{ listStyle:'none', margin:0, padding:'16px 0 0', borderTop:'1px solid var(--line)', display:'flex', flexDirection:'column', gap:10 }}>
              {['お一人何点でも応募できます','匿名でも応募できます','スマートフォンからも回答できます'].map((x,i) => (
                <li key={i} style={{ display:'flex', gap:9, fontSize:12.5, color:'var(--sub)', lineHeight:1.7 }}>
                  <span style={{ color:'var(--green)', fontWeight:800, flexShrink:0 }}>／</span>{x}
                </li>
              ))}
            </ul>
          )}
          {decided ? null : (
            <a href={formUrl} target="_blank" rel="noopener" className="btn-dark" style={{ padding:'15px 18px', borderRadius:99, fontSize:14, fontWeight:900, textAlign:'center', marginTop:4 }}>Googleフォームを開く ↗</a>
          )}
          <p style={{ fontSize:11, color:'var(--faint)', lineHeight:1.7, margin:0 }}>フォームが開けない場合は人事部人事課（内線 6533）までご連絡ください。</p>
        </div>
      </div>
    </section>
  );
}

/* ── お知らせ ＋ 行事 ── */
function NewsBoard({ announcements, events }) {
  const [cat, setCat] = useS('すべて');
  const cats = ['すべて', ...HRD.CATS];
  const list = useMemo(() => {
    const src = HRD.pub(announcements);
    const f = cat === 'すべて' ? src : src.filter(a => a.cat === cat);
    return [...f].sort((a,b) => (b.pinned?1:0)-(a.pinned?1:0) || b.date.localeCompare(a.date));
  }, [announcements, cat]);
  return (
    <section className="wrap" style={{ padding:'clamp(60px,7vw,92px) 26px' }}>
      <div className="news-layout" style={{ display:'grid', gridTemplateColumns:'1.5fr .8fr', gap:'clamp(28px,3.5vw,52px)', alignItems:'start' }}>
        <div>
          <SectionHead id="news" en="ANNOUNCEMENTS" ja="人事部からのお知らせ" action={['すべて見る','#news']} />
          <div style={{ display:'flex', gap:7, flexWrap:'wrap', marginBottom:16 }}>
            {cats.map(c => <button key={c} onClick={()=>setCat(c)} className={'chip'+(cat===c?' on':'')}>{c}</button>)}
          </div>
          <div className="card" style={{ overflow:'hidden' }}>
            {list.map((a,i) => (
              <a key={a.id} href="#" className="row" style={{ display:'flex', alignItems:'center', gap:14, padding:'15px 20px', borderTop: i===0?'none':'1px solid var(--line)', color:'var(--ink)' }}>
                <span className="num" style={{ fontSize:11.5, fontWeight:800, color:'var(--faint)', width:38, flexShrink:0 }}>{fmtDate(a.date)}</span>
                <span style={{ fontSize:10.5, fontWeight:800, color:CAT_COLORS[a.cat], background:CAT_COLORS[a.cat]+'14', padding:'4px 10px', borderRadius:99, whiteSpace:'nowrap', flexShrink:0 }}>{a.cat}</span>
                <span style={{ flex:1, fontSize:13.5, fontWeight:600, lineHeight:1.65 }}>
                  {a.pinned ? <span className="num" style={{ color:'var(--red)', fontWeight:800, marginRight:7, fontSize:10 }}>PIN</span> : null}{a.title}
                </span>
                <span style={{ fontSize:11, color:'var(--faint)', whiteSpace:'nowrap' }} className="row-author">{a.author}</span>
              </a>
            ))}
            {list.length === 0 ? <div style={{ padding:24, fontSize:13, color:'var(--faint)', textAlign:'center' }}>該当するお知らせはありません</div> : null}
          </div>
        </div>
        <div>
          <SectionHead id="events" en="CALENDAR" ja="研修・行事" />
          <div style={{ display:'flex', flexDirection:'column', gap:9 }}>
            {HRD.pub(events).map(e => (
              <a key={e.id} href="#" className="card hoverable" style={{ padding:'15px 17px', display:'flex', gap:14, alignItems:'center', color:'var(--ink)' }}>
                <div style={{ textAlign:'center', flexShrink:0, width:44 }}>
                  <div className="num" style={{ fontSize:10, fontWeight:800, color:'var(--faint)', letterSpacing:'.06em' }}>{(e.date||'').slice(5,7)}月</div>
                  <div className="num" style={{ fontSize:22, fontWeight:800, lineHeight:1.1 }}>{+(e.date||'').slice(8,10)}</div>
                </div>
                <div style={{ borderLeft:'1px solid var(--line)', paddingLeft:14, flex:1 }}>
                  <div style={{ fontSize:12.5, fontWeight:700, lineHeight:1.6, marginBottom:5, textWrap:'pretty' }}>{e.label}</div>
                  <div style={{ display:'flex', gap:8, alignItems:'center' }}>
                    <span style={{ fontSize:10, fontWeight:800, color:CAT_COLORS[e.cat], background:CAT_COLORS[e.cat]+'14', padding:'2px 8px', borderRadius:99 }}>{e.cat}</span>
                    <span style={{ fontSize:11, color:'var(--faint)' }}>{e.place}</span>
                  </div>
                </div>
              </a>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

/* ── 手続き・制度ガイド（ライフイベント別） ── */
function Guides({ guides }) {
  const list = HRD.pub(guides);
  const [open, setOpen] = useS(list[0] ? list[0].id : null);
  return (
    <section style={{ background:'var(--paper2)', borderTop:'1px solid var(--line)', borderBottom:'1px solid var(--line)' }}>
      <div className="wrap" style={{ padding:'clamp(60px,7vw,92px) 26px' }}>
        <SectionHead id="guides" en="HR GUIDE" ja="手続き・制度ガイド" note="場面ごとに必要な手続きをまとめています。様式のダウンロード、共済、マイナンバー、勤怠の詳細は各ページへ。" action={['手続き・様式のトップへ','guides.html']} />
        <div className="l2-grid" style={{ display:'grid', gridTemplateColumns:'repeat(4,1fr)', gap:12, marginBottom:14 }}>
          {[['様式ダウンロード','各種届出・申請の様式','forms.html'],['私学事業団（共済・年金）','短期給付・長期給付・福祉事業','shigaku.html'],['人事制度・発令','人事考課／発令／人員配置／事務分掌','system.html'],['勤怠・就業管理','打刻・時間外／医師はDr.JOY','attendance.html']].map(([l,dsc,u]) => (
            <a key={u} href={u} className="card hoverable" style={{ padding:'18px 20px', color:'var(--ink)', display:'flex', flexDirection:'column', gap:6, background:'var(--green-tint)', borderColor:'var(--green-tint2)' }}>
              <span style={{ fontSize:13.5, fontWeight:800, lineHeight:1.5 }}>{l}</span>
              <span style={{ fontSize:11.5, color:'var(--sub)', lineHeight:1.7 }}>{dsc}</span>
            </a>
          ))}
        </div>
        <div className="guide-grid" style={{ display:'grid', gridTemplateColumns:'repeat(4,1fr)', gap:12 }}>
          {list.map(g => {
            const on = open === g.id;
            return (
              <div key={g.id} onClick={()=>setOpen(on?null:g.id)} className="card hoverable" style={{ padding:'20px 20px 18px', cursor:'pointer', borderColor: on?'var(--ink)':'var(--line)', background:'#fff' }}>
                <div style={{ display:'flex', alignItems:'center', gap:8, marginBottom:9 }}>
                  <h3 className="disp" style={{ fontSize:15, fontWeight:900, margin:0 }}>{g.label}</h3>
                  <span className="num" style={{ marginLeft:'auto', fontSize:14, color:'var(--faint)', transform:on?'rotate(45deg)':'none', transition:'transform .2s' }}>＋</span>
                </div>
                <p style={{ fontSize:11.5, color:'var(--sub)', lineHeight:1.75, margin:0, textWrap:'pretty' }}>{g.desc}</p>
                {on ? (
                  <ul style={{ listStyle:'none', margin:'14px 0 0', padding:'14px 0 0', borderTop:'1px solid var(--line)', display:'flex', flexDirection:'column', gap:9 }}>
                    {g.links.map((l,i) => <li key={i}><a href="forms.html" style={{ fontSize:12, fontWeight:700 }}>{l} →</a></li>)}
                  </ul>
                ) : null}
              </div>
            );
          })}
        </div>
      </div>
    </section>
  );
}

/* ── コラム ＋ FAQ ── */
/* FAQ本体（検索＋タグ＋アコーディオン）。単体でも使える */
function FaqPanel({ faq, head = true }) {
  const [openQ, setOpenQ] = useS(null);
  const [q, setQ] = useS('');
  const [tag, setTag] = useS('すべて');
  const faqAll = HRD.pub(faq);
  const tags = ['すべて', ...Array.from(new Set(faqAll.flatMap(f => f.tags || [])))];
  const list = faqAll.filter(f => {
    const okTag = tag === 'すべて' || (f.tags || []).includes(tag);
    const s = q.trim();
    const okQ = !s || (f.q + f.a + (f.tags || []).join(' ')).toLowerCase().includes(s.toLowerCase());
    return okTag && okQ;
  });
  return (
    <div>
      {head ? <SectionHead id="faq" en="FAQ" ja="よくある質問" /> : null}
      <div style={{ display:'flex', flexDirection:'column', gap:10, marginBottom:14 }}>
        <input value={q} onChange={e=>setQ(e.target.value)} placeholder="キーワードで検索（例：休暇、研修、相談）" style={{ width:'100%', padding:'11px 16px', borderRadius:99, border:'1.5px solid var(--line)', background:'#fff', fontSize:13, fontFamily:'inherit', color:'var(--ink)' }} />
        <div style={{ display:'flex', gap:6, flexWrap:'wrap' }}>
          {tags.map(t => <button key={t} onClick={()=>setTag(t)} className={'chip'+(tag===t?' on':'')}>{t==='すべて'?t:'#'+t}</button>)}
        </div>
      </div>
      <div className="card" style={{ overflow:'hidden' }}>
        {list.map((f,i) => {
          const on = openQ === f.id;
          return (
            <div key={f.id} style={{ borderTop: i===0?'none':'1px solid var(--line)' }}>
              <button onClick={()=>setOpenQ(on?null:f.id)} style={{ width:'100%', textAlign:'left', display:'flex', gap:12, alignItems:'center', padding:'16px 20px', background:'none', border:'none', cursor:'pointer', fontFamily:'inherit', color:'var(--ink)' }}>
                <span className="num" style={{ fontSize:12, fontWeight:800, color:'var(--green)' }}>Q</span>
                <span style={{ flex:1, fontSize:13, fontWeight:700, lineHeight:1.65 }}>{f.q}</span>
                <span className="num" style={{ fontSize:13, color:'var(--faint)', transform:on?'rotate(45deg)':'none', transition:'transform .2s' }}>＋</span>
              </button>
              {on ? (
                <div style={{ padding:'0 20px 18px 44px' }}>
                  <div style={{ fontSize:12.5, color:'var(--sub)', lineHeight:1.95, textWrap:'pretty' }}>{f.a}</div>
                  {(f.tags || []).length ? (
                    <div style={{ display:'flex', gap:6, flexWrap:'wrap', marginTop:12 }}>
                      {f.tags.map(t => <button key={t} onClick={(e)=>{e.stopPropagation();setTag(t);}} style={{ fontSize:10.5, fontWeight:700, color:'var(--green)', background:'var(--green-tint)', border:'none', padding:'3px 9px', borderRadius:99, cursor:'pointer', fontFamily:'inherit' }}>#{t}</button>)}
                    </div>
                  ) : null}
                </div>
              ) : null}
            </div>
          );
        })}
        {list.length === 0 ? <div style={{ padding:24, fontSize:12.5, color:'var(--faint)', textAlign:'center' }}>該当する質問が見つかりませんでした。</div> : null}
      </div>
    </div>
  );
}

/* 人事部コラム */
function ColumnsPanel({ columns }) {
  return (
    <div>
      <SectionHead en="HR COLUMN" ja="人事部コラム" />
      <div style={{ display:'flex', flexDirection:'column', gap:10 }}>
        {HRD.pub(columns).map(c => (
          <a key={c.id} href="#" className="card hoverable" style={{ padding:'18px 20px', color:'var(--ink)', display:'flex', flexDirection:'column', gap:9 }}>
            <div style={{ display:'flex', alignItems:'center', gap:9 }}>
              <span style={{ fontSize:10.5, fontWeight:800, color:'var(--green)', background:'var(--green-tint)', padding:'3px 9px', borderRadius:99 }}>{c.tag}</span>
              <span className="num" style={{ fontSize:11, color:'var(--faint)', fontWeight:700 }}>{fmtDate(c.date)}</span>
              <span className="num" style={{ fontSize:10.5, color:'var(--faint)', marginLeft:'auto' }}>{c.read}</span>
            </div>
            <div style={{ fontSize:14, fontWeight:700, lineHeight:1.65, textWrap:'pretty' }}>{c.title}</div>
          </a>
        ))}
      </div>
    </div>
  );
}

/* トップページ用：コラム＋FAQの2カラム */
function ColumnsFaq({ columns, faq }) {
  return (
    <section className="wrap" style={{ padding:'clamp(60px,7vw,92px) 26px' }}>
      <div className="news-layout" style={{ display:'grid', gridTemplateColumns:'1fr 1fr', gap:'clamp(28px,3.5vw,52px)', alignItems:'start' }}>
        <ColumnsPanel columns={columns} />
        <FaqPanel faq={faq} />
      </div>
    </section>
  );
}

/* ── 声を届ける ── */
function Voice({ voice }) {
  return (
    <section id="voice" style={{ background:'#fff', color:'var(--ink)', position:'relative', overflow:'hidden', borderTop:'1px solid var(--line)', scrollMarginTop:70 }}>
      <ConnectCanvas motion={true} rgb="27,107,84" opacity={.26} strength={.9} />
      <div className="wrap" style={{ position:'relative', padding:'clamp(56px,6.5vw,88px) 26px' }}>
        <div className="voice-grid" style={{ display:'grid', gridTemplateColumns:'.9fr 1.1fr', gap:'clamp(28px,4vw,60px)', alignItems:'center' }}>
          <div>
            <div className="num" style={{ fontSize:10.5, fontWeight:800, letterSpacing:'.18em', color:'var(--green)', marginBottom:14 }}>YOUR VOICE</div>
            <h2 className="disp" style={{ fontSize:'clamp(22px,2.6vw,32px)', fontWeight:900, lineHeight:1.45, margin:'0 0 16px', textWrap:'pretty' }}>{voice.title}</h2>
            <p style={{ fontSize:13.5, color:'var(--sub)', lineHeight:2, margin:0, textWrap:'pretty' }}>{voice.body}</p>
          </div>
          <div style={{ display:'grid', gridTemplateColumns:'1fr 1fr', gap:11 }}>
            {HRD.pub(voice.channels).map(ch => (
              <a key={ch.id} href={ch.url} className="voice-card" style={{ padding:'20px 20px', borderRadius:14, border:'1px solid var(--line)', background:'var(--paper)', color:'var(--ink)', display:'flex', flexDirection:'column', gap:7 }}>
                <span style={{ fontSize:13.5, fontWeight:800 }}>{ch.label}</span>
                <span style={{ fontSize:11.5, color:'var(--sub)', lineHeight:1.7 }}>{ch.desc}</span>
              </a>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

function Footer({ contacts = [], note = '', nav = NAV }) {
  const list = HRD.pub(contacts);
  return (
    <footer style={{ background:'#fff', borderTop:'1px solid var(--line)' }}>
      <div className="wrap" style={{ padding:'clamp(40px,4vw,56px) 26px' }}>
        <div className="foot-grid" style={{ display:'grid', gridTemplateColumns:'1.1fr .8fr', gap:'clamp(24px,3vw,48px)', marginBottom:32 }}>
          <div>
            <Logo />
            <p style={{ fontSize:12, color:'var(--sub)', lineHeight:1.9, margin:'16px 0 0', maxWidth:320, textWrap:'pretty' }}>
              学校法人兵庫医科大学 人事部が運営する教職員向け情報サイトです。法人全体のポータルは広報課にて準備中です。
            </p>
          </div>
          <nav style={{ display:'flex', flexDirection:'column', gap:9 }}>
            <div className="num" style={{ fontSize:10, fontWeight:800, letterSpacing:'.14em', color:'var(--faint)', marginBottom:4 }}>SITE MAP</div>
            {nav.map(([l,h]) => <a key={h} href={h} style={{ fontSize:12.5, color:'var(--sub)', fontWeight:600 }}>{l}</a>)}
          </nav>
        </div>
        <div style={{ marginBottom:30 }}>
          <div className="num" style={{ fontSize:10, fontWeight:800, letterSpacing:'.14em', color:'var(--faint)', marginBottom:13 }}>CONTACT</div>
          <div className="foot-contacts" style={{ display:'grid', gridTemplateColumns:'repeat(4,1fr)', gap:12 }}>
            {list.map(c => (
              <div key={c.id} style={{ padding:'16px 18px', border:'1px solid var(--line)', borderRadius:12, background:'var(--paper)' }}>
                <div style={{ fontSize:13, fontWeight:800, marginBottom:4 }}>{c.dept}</div>
                {c.role ? <div style={{ fontSize:11, color:'var(--faint)', marginBottom:9, lineHeight:1.6 }}>{c.role}</div> : null}
                <div style={{ fontSize:12, color:'var(--sub)', lineHeight:1.9 }}>
                  {c.mail ? <div>Mail：<a href={'mailto:'+c.mail}>{c.mail}</a></div> : null}
                  {c.tel ? <div>Tel：{c.tel}</div> : null}
                </div>
              </div>
            ))}
          </div>
          {note ? <p style={{ fontSize:11.5, color:'var(--faint)', lineHeight:1.8, margin:'12px 0 0' }}>{note}</p> : null}
        </div>
        <div style={{ paddingTop:20, borderTop:'1px solid var(--line)', display:'flex', gap:14, flexWrap:'wrap', alignItems:'center' }}>
          <span className="num" style={{ fontSize:10.5, color:'var(--faint)' }}>© 2026 Hyogo Medical University — Human Resources Department</span>
          <a href="cms.html" style={{ marginLeft:'auto', fontSize:11.5, fontWeight:700, color:'var(--faint)' }}>CMS管理画面 →</a>
        </div>
      </div>
    </footer>
  );
}

Object.assign(window, { NoticeModal, NoticeLetter, Initiatives, SloganCall, NewsBoard, Guides, ColumnsFaq, FaqPanel, ColumnsPanel, Voice, Footer });
