// mobile-screens.jsx — Public marketing screens (Home, Programs, Faculty, Trial)
// Mobile uses the same TOKENS, fonts, palette, copy, and hairline visual vocabulary
// as the desktop prototype. Patterns adapted for touch: scrollable hero,
// vertical card stacks, sticky CTAs, sheet-style filters.

const MOBILE_W = 402;
const MOBILE_H = 874;

// ── Mobile chrome ─────────────────────────────────────────────
function MTopBar({ dark, lang, headingFont, onMenu, onBack, title, transparent }) {
  const p = palette(dark);
  return (
    <div style={{
      position: 'sticky', top: 0, zIndex: 5,
      display: 'flex', alignItems: 'center', justifyContent: 'space-between',
      padding: '12px 18px', height: 52,
      background: transparent ? 'transparent' : p.paper,
      borderBottom: transparent ? 'none' : `0.5px solid ${p.line}`,
      backdropFilter: transparent ? undefined : 'blur(8px)',
    }}>
      {onBack ? (
        <button onClick={onBack} style={{ background: 'none', border: 'none', padding: 0, cursor: 'pointer', display: 'flex', alignItems: 'center', gap: 4, color: p.ink, fontFamily: TOKENS.font.sans, fontSize: 15 }}>
          <svg width="11" height="18" viewBox="0 0 11 18" fill="none"><path d="M9 1L2 9l7 8" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round"/></svg>
        </button>
      ) : (
        <Logotype dark={dark} size={13} serif={headingFont === 'serif'} />
      )}
      {title && (
        <div style={{ position: 'absolute', left: 0, right: 0, textAlign: 'center', pointerEvents: 'none', fontFamily: TOKENS.font.sans, fontSize: 15, fontWeight: 600, color: p.ink }}>{title}</div>
      )}
      <button onClick={onMenu} style={{ background: 'none', border: 'none', padding: 0, cursor: 'pointer', color: p.ink }}>
        <svg width="22" height="22" viewBox="0 0 22 22" fill="none"><path d="M3 7h16M3 11h16M3 15h16" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round"/></svg>
      </button>
    </div>
  );
}

function MStickyCTA({ dark, children }) {
  const p = palette(dark);
  return (
    <div style={{
      position: 'sticky', bottom: 0, left: 0, right: 0,
      padding: '14px 18px 22px',
      background: `linear-gradient(to top, ${p.paper} 60%, ${p.paper}00)`,
      borderTop: `0.5px solid ${p.line}`,
    }}>{children}</div>
  );
}

function MTabBar({ dark, items, active, onSelect }) {
  const p = palette(dark);
  return (
    <div style={{
      display: 'grid', gridTemplateColumns: `repeat(${items.length}, 1fr)`,
      borderTop: `0.5px solid ${p.line}`, background: p.paper,
      paddingBottom: 0,
    }}>
      {items.map(it => {
        const on = it.id === active;
        return (
          <button key={it.id} onClick={() => onSelect && onSelect(it.id)} style={{
            background: 'none', border: 'none', cursor: 'pointer',
            padding: '10px 4px 14px', display: 'flex', flexDirection: 'column',
            alignItems: 'center', gap: 4, color: on ? p.ink : p.inkMuted,
          }}>
            <div style={{ width: 22, height: 22, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>{it.icon}</div>
            <span style={{ fontFamily: TOKENS.font.sans, fontSize: 10, letterSpacing: 0.2, fontWeight: on ? 600 : 400 }}>{it.label}</span>
          </button>
        );
      })}
    </div>
  );
}

// Tiny line icons — minimal, hairline weight
const Icons = {
  home: <svg width="22" height="22" viewBox="0 0 22 22" fill="none"><path d="M3 9l8-6 8 6v10a1 1 0 01-1 1h-4v-7H8v7H4a1 1 0 01-1-1V9z" stroke="currentColor" strokeWidth="1.4" strokeLinejoin="round"/></svg>,
  calendar: <svg width="22" height="22" viewBox="0 0 22 22" fill="none"><rect x="3" y="5" width="16" height="14" rx="1.5" stroke="currentColor" strokeWidth="1.4"/><path d="M3 9h16M7 3v4M15 3v4" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round"/></svg>,
  bill: <svg width="22" height="22" viewBox="0 0 22 22" fill="none"><path d="M5 3h12v17l-3-2-3 2-3-2-3 2V3z" stroke="currentColor" strokeWidth="1.4" strokeLinejoin="round"/><path d="M8 8h6M8 12h6" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round"/></svg>,
  msg: <svg width="22" height="22" viewBox="0 0 22 22" fill="none"><path d="M3 5a2 2 0 012-2h12a2 2 0 012 2v9a2 2 0 01-2 2H9l-5 4v-4H5a2 2 0 01-2-2V5z" stroke="currentColor" strokeWidth="1.4" strokeLinejoin="round"/></svg>,
  user: <svg width="22" height="22" viewBox="0 0 22 22" fill="none"><circle cx="11" cy="8" r="3.5" stroke="currentColor" strokeWidth="1.4"/><path d="M4 19c0-3.5 3-6 7-6s7 2.5 7 6" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round"/></svg>,
  notes: <svg width="22" height="22" viewBox="0 0 22 22" fill="none"><rect x="4" y="3" width="14" height="16" rx="1.5" stroke="currentColor" strokeWidth="1.4"/><path d="M7 7h8M7 11h8M7 15h5" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round"/></svg>,
  chart: <svg width="22" height="22" viewBox="0 0 22 22" fill="none"><path d="M3 19h16M6 15v-4M10 15V7M14 15v-6M18 15v-2" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round"/></svg>,
  search: <svg width="22" height="22" viewBox="0 0 22 22" fill="none"><circle cx="10" cy="10" r="6" stroke="currentColor" strokeWidth="1.4"/><path d="M15 15l4 4" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round"/></svg>,
  qr: <svg width="22" height="22" viewBox="0 0 22 22" fill="none"><rect x="3" y="3" width="6" height="6" stroke="currentColor" strokeWidth="1.4"/><rect x="13" y="3" width="6" height="6" stroke="currentColor" strokeWidth="1.4"/><rect x="3" y="13" width="6" height="6" stroke="currentColor" strokeWidth="1.4"/><path d="M13 13h2v2M19 13v2M13 17v2M17 17h2" stroke="currentColor" strokeWidth="1.4"/></svg>,
};

// ── 1. HOME (mobile marketing) ────────────────────────────────
function MPageHome({ dark, lang, headingFont }) {
  const p = palette(dark);
  const t = STRINGS[lang];
  const en = lang === 'en';
  const programs = en ? [
    { name: 'Private Lessons', sub: 'One-to-one, weekly', meta: 'Piano · Strings · Voice · Winds', age: '5+' },
    { name: 'Group Classes', sub: '4–8 students', meta: 'Theory · Ensemble · Choir', age: '6–17' },
    { name: 'Summer Camps', sub: 'Two-week intensives', meta: 'Performance · Composition', age: '7–14' },
  ] : [
    { name: '私人课', sub: '一对一周课', meta: '钢琴 · 弦乐 · 声乐 · 管乐', age: '5+' },
    { name: '小组课', sub: '4–8 人小班', meta: '乐理 · 合奏 · 合唱', age: '6–17' },
    { name: '夏令营', sub: '两周密集营', meta: '演奏 · 作曲', age: '7–14' },
  ];

  return (
    <div style={{ background: p.paper, color: p.ink, minHeight: '100%', display: 'flex', flexDirection: 'column' }}>
      <MTopBar dark={dark} lang={lang} headingFont={headingFont} />

      {/* Hero */}
      <div style={{ padding: '28px 22px 36px' }}>
        <Mono dark={dark} style={{ marginBottom: 16, display: 'inline-block', fontSize: 9 }}>{t.hero.eyebrow}</Mono>
        <H as="h1" dark={dark} font={headingFont} size={36} style={{ marginBottom: 16, whiteSpace: 'pre-line', letterSpacing: -0.6 }}>{t.hero.title}</H>
        <p style={{ fontFamily: TOKENS.font.sans, fontSize: 14, color: p.inkSoft, lineHeight: 1.55, margin: '0 0 20px' }}>{t.hero.sub}</p>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
          <Button dark={dark} variant="primary" size="lg" fullWidth>{t.cta.trial}</Button>
          <Button dark={dark} variant="secondary" size="lg" fullWidth>{t.cta.learnMore} →</Button>
        </div>
      </div>

      {/* Stats strip */}
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 0, borderTop: `0.5px solid ${p.line}`, borderBottom: `0.5px solid ${p.line}` }}>
        {t.hero.meta.map((m, i) => (
          <div key={i} style={{ padding: '18px 14px', borderRight: i < 2 ? `0.5px solid ${p.line}` : 'none' }}>
            <Mono dark={dark} style={{ fontSize: 9 }}>{String(i + 1).padStart(2, '0')}</Mono>
            <div style={{ fontFamily: TOKENS.font.sans, fontSize: 11, color: p.ink, marginTop: 4, lineHeight: 1.3 }}>{m}</div>
          </div>
        ))}
      </div>

      {/* Programs */}
      <div style={{ padding: '32px 22px 24px', background: p.paperSoft }}>
        <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', marginBottom: 18 }}>
          <H as="h2" dark={dark} font={headingFont} size={22}>{t.sections.programs}</H>
          <Mono dark={dark} style={{ fontSize: 9 }}>03 / paths</Mono>
        </div>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
          {programs.map((pr, i) => (
            <div key={i} style={{ background: p.paper, border: `0.5px solid ${p.line}`, borderRadius: TOKENS.radius.md, overflow: 'hidden' }}>
              <Stripes dark={dark} ratio="16 / 7" label={`studio ${i + 1}`} />
              <div style={{ padding: '16px 18px' }}>
                <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'baseline' }}>
                  <H as="h3" dark={dark} font={headingFont} size={18}>{pr.name}</H>
                  <Pill dark={dark} tone="neutral" style={{ fontSize: 10 }}>{pr.age}</Pill>
                </div>
                <div style={{ fontFamily: TOKENS.font.sans, fontSize: 12, color: p.inkSoft, marginTop: 4 }}>{pr.sub}</div>
                <div style={{ fontFamily: TOKENS.font.sans, fontSize: 11, color: p.inkMuted, marginTop: 10 }}>{pr.meta}</div>
              </div>
            </div>
          ))}
        </div>
      </div>

      {/* Proof block */}
      <div style={{ padding: '36px 22px 28px' }}>
        <Mono dark={dark} style={{ marginBottom: 12, display: 'inline-block', fontSize: 9 }}>{en ? '23 years on UBC campus' : '驻 UBC 校园 23 年'}</Mono>
        <H as="h2" dark={dark} font={headingFont} size={26} style={{ marginBottom: 14 }}>{t.sections.proof}</H>
        <p style={{ fontFamily: TOKENS.font.sans, fontSize: 13, color: p.inkSoft, lineHeight: 1.65, margin: 0 }}>
          {en ? 'Thirty faculty. Seven studios. Two classrooms. Year-round recitals. We teach the way good music is learned — slowly, patiently, with people who listen.' : '三十位教师。七间琴房。两间教室。全年汇报演出。我们以好音乐被学会的方式去教——慢一些，耐心一些，让会倾听的人陪伴学生。'}
        </p>
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 1, marginTop: 22, background: p.line, border: `0.5px solid ${p.line}` }}>
          {[{ n: '30', l: en ? 'Faculty' : '教师' }, { n: '420+', l: en ? 'Students' : '在校学生' }, { n: '12', l: en ? 'Recitals/yr' : '年度演出' }, { n: '4.9', l: en ? 'Parent rating' : '家长评分' }].map((s, i) => (
            <div key={i} style={{ background: p.paper, padding: '20px 16px' }}>
              <H as="div" dark={dark} font={headingFont} size={28} weight={500} style={{ letterSpacing: -1, marginBottom: 4 }}>{s.n}</H>
              <Mono dark={dark} style={{ fontSize: 9 }}>{s.l}</Mono>
            </div>
          ))}
        </div>
      </div>

      {/* FAQ */}
      <div style={{ padding: '24px 22px 32px', borderTop: `0.5px solid ${p.line}` }}>
        <H as="h2" dark={dark} font={headingFont} size={22} style={{ marginBottom: 14 }}>{t.sections.faq}</H>
        {[
          { q: en ? 'How does the trial lesson work?' : '试听课怎么进行？', open: true,
            a: en ? 'A 30-minute paid trial with the matched teacher. The fee is credited toward your first month if you enroll within 14 days.' : '与匹配教师进行 30 分钟付费试听。14 天内注册可抵扣首月学费。' },
          { q: en ? 'Do you offer makeup lessons?' : '可以补课吗？' },
          { q: en ? 'What instruments do you teach?' : '教授哪些乐器？' },
          { q: en ? 'How is tuition billed?' : '学费如何收取？' },
        ].map((f, i) => (
          <div key={i} style={{ borderBottom: `0.5px solid ${p.line}`, padding: '14px 0' }}>
            <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 12 }}>
              <div style={{ fontFamily: TOKENS.font.sans, fontSize: 13, color: p.ink, fontWeight: 500 }}>{f.q}</div>
              <span style={{ color: p.inkMuted, fontSize: 16 }}>{f.open ? '−' : '+'}</span>
            </div>
            {f.open && f.a && <div style={{ fontFamily: TOKENS.font.sans, fontSize: 12, color: p.inkSoft, marginTop: 8, lineHeight: 1.55 }}>{f.a}</div>}
          </div>
        ))}
      </div>

      <div style={{ flex: 1 }} />
      <MStickyCTA dark={dark}>
        <Button dark={dark} variant="primary" size="lg" fullWidth>{t.cta.trial}</Button>
      </MStickyCTA>
    </div>
  );
}

// ── 2. PROGRAMS ───────────────────────────────────────────────
function MPagePrograms({ dark, lang, headingFont, showPricing = true }) {
  const p = palette(dark);
  const en = lang === 'en';
  const [filter, setFilter] = React.useState('all');

  const filters = en
    ? [{ id: 'all', l: 'All' }, { id: 'private', l: 'Private' }, { id: 'group', l: 'Group' }, { id: 'theory', l: 'Theory' }]
    : [{ id: 'all', l: '全部' }, { id: 'private', l: '私人课' }, { id: 'group', l: '小组' }, { id: 'theory', l: '乐理' }];

  const items = en ? [
    { tag: 'Private', name: 'Piano — One-to-one', age: '5+', dur: '30 / 45 / 60 min', price: '$45 / 30 min', meta: 'Weekly · 9 faculty available' },
    { tag: 'Private', name: 'Violin — One-to-one', age: '5+', dur: '30 / 45 min', price: '$48 / 30 min', meta: 'Weekly · 4 faculty available' },
    { tag: 'Group', name: 'Choir — Junior', age: '7–11', dur: '60 min', price: '$28 / class', meta: 'Tuesdays · 6:00 pm' },
    { tag: 'Group', name: 'String Ensemble', age: '10–17', dur: '90 min', price: '$36 / class', meta: 'Saturdays · 2:00 pm' },
    { tag: 'Theory', name: 'RCM Theory Prep', age: '10+', dur: '60 min', price: '$32 / class', meta: 'By cohort · 8-week term' },
    { tag: 'Camp', name: 'Summer Composition Camp', age: '12–14', dur: '2 weeks', price: '$680', meta: 'Aug 4–15 · daily 10–3' },
  ] : [
    { tag: '私人课', name: '钢琴 · 一对一', age: '5+', dur: '30 / 45 / 60 分钟', price: '¥45 / 30 分钟', meta: '每周 · 9 位教师' },
    { tag: '私人课', name: '小提琴 · 一对一', age: '5+', dur: '30 / 45 分钟', price: '¥48 / 30 分钟', meta: '每周 · 4 位教师' },
    { tag: '小组', name: '少年合唱团', age: '7–11', dur: '60 分钟', price: '¥28 / 节', meta: '周二 · 18:00' },
    { tag: '小组', name: '弦乐合奏', age: '10–17', dur: '90 分钟', price: '¥36 / 节', meta: '周六 · 14:00' },
    { tag: '乐理', name: 'RCM 乐理预备班', age: '10+', dur: '60 分钟', price: '¥32 / 节', meta: '分组 · 8 周一期' },
    { tag: '夏令营', name: '夏季作曲营', age: '12–14', dur: '两周', price: '¥680', meta: '8/4–15 · 每日 10–15' },
  ];

  return (
    <div style={{ background: p.paper, color: p.ink, minHeight: '100%' }}>
      <MTopBar dark={dark} lang={lang} headingFont={headingFont} />
      <div style={{ padding: '20px 22px 16px' }}>
        <Mono dark={dark} style={{ fontSize: 9 }}>{en ? '06 programs' : '6 个项目'}</Mono>
        <H as="h1" dark={dark} font={headingFont} size={30} style={{ marginTop: 8 }}>{en ? 'Programs & pricing' : '课程与学费'}</H>
        <p style={{ fontFamily: TOKENS.font.sans, fontSize: 13, color: p.inkSoft, lineHeight: 1.55, marginTop: 10, marginBottom: 0 }}>
          {en ? 'Pick a path. Most students start with a 30-min weekly private lesson and add a group class in the second term.' : '选择一条路径。大多数学生从每周 30 分钟私人课开始，并在第二学期加入小组课。'}
        </p>
      </div>

      {/* Filter chips */}
      <div style={{ padding: '4px 22px 16px', display: 'flex', gap: 8, overflowX: 'auto', borderBottom: `0.5px solid ${p.line}` }}>
        {filters.map(f => {
          const on = filter === f.id;
          return (
            <button key={f.id} onClick={() => setFilter(f.id)} style={{
              padding: '7px 14px', borderRadius: 999, border: `0.5px solid ${on ? p.ink : p.line}`,
              background: on ? p.ink : 'transparent', color: on ? p.paper : p.inkSoft,
              fontFamily: TOKENS.font.sans, fontSize: 12, fontWeight: 500, whiteSpace: 'nowrap', cursor: 'pointer',
            }}>{f.l}</button>
          );
        })}
      </div>

      <div style={{ padding: '8px 0 32px' }}>
        {items.map((it, i) => (
          <div key={i} style={{ padding: '18px 22px', borderBottom: `0.5px solid ${p.line}` }}>
            <div style={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 12, marginBottom: 6 }}>
              <Mono dark={dark} style={{ fontSize: 9 }}>{it.tag} · {en ? 'ages' : '年龄'} {it.age}</Mono>
              {showPricing && <span style={{ fontFamily: TOKENS.font.sans, fontSize: 13, color: p.ink, fontWeight: 600 }}>{it.price}</span>}
            </div>
            <H as="h3" dark={dark} font={headingFont} size={18} style={{ marginBottom: 4 }}>{it.name}</H>
            <div style={{ fontFamily: TOKENS.font.sans, fontSize: 12, color: p.inkSoft }}>{it.dur} · {it.meta}</div>
          </div>
        ))}
      </div>

      <MStickyCTA dark={dark}>
        <Button dark={dark} variant="primary" size="lg" fullWidth>{en ? 'Book a 30-min trial' : '预约 30 分钟试听'}</Button>
      </MStickyCTA>
    </div>
  );
}

// ── 3. FACULTY DETAIL ─────────────────────────────────────────
function MPageFaculty({ dark, lang, headingFont }) {
  const p = palette(dark);
  const en = lang === 'en';
  return (
    <div style={{ background: p.paper, color: p.ink, minHeight: '100%' }}>
      <MTopBar dark={dark} lang={lang} headingFont={headingFont} onBack={() => {}} />

      {/* Portrait */}
      <Stripes dark={dark} height={280} label="faculty portrait" style={{ borderRadius: 0, borderLeft: 'none', borderRight: 'none' }} />

      <div style={{ padding: '24px 22px 18px' }}>
        <Mono dark={dark} style={{ fontSize: 9 }}>{en ? 'Piano · Senior faculty' : '钢琴 · 资深教师'}</Mono>
        <H as="h1" dark={dark} font={headingFont} size={30} style={{ marginTop: 6 }}>{en ? 'Ji-eun Park' : '朴智恩'}</H>
        <div style={{ display: 'flex', gap: 6, marginTop: 12, flexWrap: 'wrap' }}>
          <Pill dark={dark} tone="gold">{en ? 'Accepting students' : '接收学生'}</Pill>
          <Pill dark={dark} tone="neutral">{en ? '14 yrs at studio' : '驻校 14 年'}</Pill>
          <Pill dark={dark} tone="neutral">RCM</Pill>
        </div>
        <p style={{ fontFamily: TOKENS.font.serif, fontSize: 18, fontStyle: 'italic', color: p.inkSoft, lineHeight: 1.5, marginTop: 22 }}>
          {en ? '“I teach the music first, then the technique that lets the music sound the way you heard it in your head.”' : '"我先教音乐，然后再教那些能让音乐听起来与你脑海中一致的技术。"'}
        </p>
      </div>

      {/* Bio */}
      <div style={{ padding: '4px 22px 22px' }}>
        <Mono dark={dark} style={{ fontSize: 9 }}>{en ? 'Background' : '背景'}</Mono>
        <p style={{ fontFamily: TOKENS.font.sans, fontSize: 13, color: p.inkSoft, lineHeight: 1.7, marginTop: 8 }}>
          {en ? 'Seoul National University (BMus). Manhattan School of Music (MM). Performances at the Kennedy Center, Roy Thomson Hall, and Chan Centre. Studio focus: classical foundation with chamber and contemporary repertoire from the second year.' : '首尔大学（音乐学士）。曼哈顿音乐学院（音乐硕士）。曾在肯尼迪中心、罗伊·汤姆森音乐厅、陈氏中心演出。教学重点：古典基础，从第二年起加入室内乐与当代曲目。'}
        </p>
      </div>

      {/* Tuition rows */}
      <div style={{ background: p.paperSoft, padding: '18px 22px', borderTop: `0.5px solid ${p.line}`, borderBottom: `0.5px solid ${p.line}` }}>
        <Mono dark={dark} style={{ fontSize: 9, marginBottom: 12, display: 'block' }}>{en ? 'Tuition with this faculty' : '该教师学费'}</Mono>
        {[
          { d: '30 min · weekly', a: '$48' },
          { d: '45 min · weekly', a: '$66' },
          { d: '60 min · weekly', a: '$84' },
        ].map((r, i) => (
          <div key={i} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '12px 0', borderTop: i > 0 ? `0.5px solid ${p.line}` : 'none' }}>
            <span style={{ fontFamily: TOKENS.font.sans, fontSize: 13, color: p.ink }}>{r.d}</span>
            <span style={{ fontFamily: TOKENS.font.sans, fontSize: 14, fontWeight: 600 }}>{r.a}</span>
          </div>
        ))}
      </div>

      {/* Available slots */}
      <div style={{ padding: '22px 22px 28px' }}>
        <H as="h2" dark={dark} font={headingFont} size={18} style={{ marginBottom: 12 }}>{en ? 'Open trial slots this week' : '本周可试听时段'}</H>
        <div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: 10 }}>
          {[
            { d: en ? 'Wed Mar 6' : '3/6 周三', t: '4:15 pm' },
            { d: en ? 'Wed Mar 6' : '3/6 周三', t: '5:00 pm' },
            { d: en ? 'Thu Mar 7' : '3/7 周四', t: '3:30 pm' },
            { d: en ? 'Sat Mar 9' : '3/9 周六', t: '11:00 am' },
          ].map((s, i) => (
            <div key={i} style={{ padding: '14px 12px', border: `0.5px solid ${p.line}`, borderRadius: TOKENS.radius.md, background: p.paper }}>
              <Mono dark={dark} style={{ fontSize: 9 }}>{s.d}</Mono>
              <div style={{ fontFamily: TOKENS.font.sans, fontSize: 15, fontWeight: 500, marginTop: 4 }}>{s.t}</div>
            </div>
          ))}
        </div>
      </div>

      <MStickyCTA dark={dark}>
        <Button dark={dark} variant="primary" size="lg" fullWidth>{en ? 'Book a trial with Ji-eun' : '预约朴老师试听'}</Button>
      </MStickyCTA>
    </div>
  );
}

// ── 4. TRIAL BOOKING ──────────────────────────────────────────
function MPageTrial({ dark, lang, headingFont }) {
  const p = palette(dark);
  const en = lang === 'en';
  const [step, setStep] = React.useState(2);

  const days = en
    ? ['Mon 4', 'Tue 5', 'Wed 6', 'Thu 7', 'Fri 8', 'Sat 9']
    : ['周一', '周二', '周三', '周四', '周五', '周六'];

  return (
    <div style={{ background: p.paper, color: p.ink, minHeight: '100%' }}>
      <MTopBar dark={dark} lang={lang} headingFont={headingFont} onBack={() => {}} title={en ? 'Book a trial' : '预约试听'} />

      {/* Stepper */}
      <div style={{ padding: '14px 22px 8px', display: 'flex', gap: 6 }}>
        {[1, 2, 3].map(n => (
          <div key={n} style={{ flex: 1, height: 3, borderRadius: 2, background: n <= step ? p.gold : p.line }} />
        ))}
      </div>

      <div style={{ padding: '12px 22px 16px' }}>
        <Mono dark={dark} style={{ fontSize: 9 }}>{en ? `Step ${step} of 3` : `第 ${step} / 3 步`}</Mono>
        <H as="h1" dark={dark} font={headingFont} size={26} style={{ marginTop: 6 }}>{en ? 'Pick a day & time' : '选择日期与时间'}</H>
        <div style={{ fontFamily: TOKENS.font.sans, fontSize: 12, color: p.inkSoft, marginTop: 6 }}>{en ? 'With Ji-eun Park · Piano · 30 min · $25' : '朴智恩 · 钢琴 · 30 分钟 · ¥25'}</div>
      </div>

      {/* Day strip */}
      <div style={{ padding: '0 22px 16px', display: 'grid', gridTemplateColumns: 'repeat(6, 1fr)', gap: 6 }}>
        {days.map((d, i) => {
          const on = i === 2;
          return (
            <div key={i} style={{
              padding: '10px 0', borderRadius: TOKENS.radius.md,
              background: on ? p.ink : 'transparent',
              border: `0.5px solid ${on ? p.ink : p.line}`,
              color: on ? p.paper : p.inkSoft,
              textAlign: 'center', fontFamily: TOKENS.font.sans, fontSize: 11, fontWeight: 500,
            }}>
              {d}
            </div>
          );
        })}
      </div>

      {/* Time slots */}
      <div style={{ padding: '4px 22px 18px', display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 8 }}>
        {['3:30', '4:00', '4:15', '4:45', '5:00', '5:30', '6:00', '6:30', '7:00'].map((tm, i) => {
          const on = tm === '4:15';
          const taken = ['3:30', '5:30'].includes(tm);
          return (
            <button key={i} disabled={taken} style={{
              padding: '12px 0', borderRadius: TOKENS.radius.md,
              background: on ? p.gold : 'transparent',
              border: `0.5px solid ${on ? p.gold : p.line}`,
              color: on ? '#fff' : (taken ? p.inkMuted : p.ink),
              opacity: taken ? 0.4 : 1,
              fontFamily: TOKENS.font.sans, fontSize: 13, fontWeight: 500,
              textDecoration: taken ? 'line-through' : 'none',
              cursor: taken ? 'not-allowed' : 'pointer',
            }}>{tm}</button>
          );
        })}
      </div>

      {/* Summary */}
      <div style={{ margin: '6px 22px', padding: '16px 18px', background: p.paperSoft, borderRadius: TOKENS.radius.md, border: `0.5px solid ${p.line}` }}>
        <Mono dark={dark} style={{ fontSize: 9 }}>{en ? 'Selected' : '已选'}</Mono>
        <H as="div" dark={dark} font={headingFont} size={18} style={{ marginTop: 6 }}>{en ? 'Wed Mar 6 · 4:15 pm' : '3/6 周三 · 下午 4:15'}</H>
        <div style={{ fontFamily: TOKENS.font.sans, fontSize: 12, color: p.inkSoft, marginTop: 4 }}>{en ? 'Studio B-3 · 30 min trial · $25' : 'B-3 琴房 · 30 分钟试听 · ¥25'}</div>
      </div>

      <div style={{ flex: 1 }} />
      <MStickyCTA dark={dark}>
        <Button dark={dark} variant="primary" size="lg" fullWidth>{en ? 'Continue to details →' : '继续填写资料 →'}</Button>
      </MStickyCTA>
    </div>
  );
}

Object.assign(window, {
  MOBILE_W, MOBILE_H, MTopBar, MStickyCTA, MTabBar, Icons,
  MPageHome, MPagePrograms, MPageFaculty, MPageTrial,
});
