// 知乎 — 消息 (Messages) hub + 4 sub-pages, each with [以往 | 镜像回答] tabs.

const M_BG = '#0B0D11';
const M_TEXT = '#EDEEF0';
const M_MUTED = '#7A8089';
const M_DIM = '#4A4F57';
const M_BLUE = '#1772F6';
const M_BLUE_DIM = '#163861';
const M_DIVIDER = '#1B1D22';
const M_CARD = '#15171C';
const M_RED = '#E53935';

// ---------- Data (original) ----------
const M_CATEGORIES = [
  { id: 'cmt',  label: '评论转发@', icon: 'bubble' },
  { id: 'like', label: '赞同喜欢',   icon: 'heart' },
  { id: 'fav',  label: '收藏了我',   icon: 'star' },
  { id: 'sub',  label: '关注订阅',   icon: 'eye' },
];

const M_THREADS = [
  { id: 't0', kind: 'invite', title: '邀请回答', subtitle: '推荐问题邀你回答', bg: '#1A75E0' },
  { id: 't1', kind: 'q', title: '关注的问题有了新回答', subtitle: '提问 / 邀请 / 关注的问题有了新回答', time: '11:16', badge: '1', bg: '#1A75E0', icon: 'q' },
  { id: 't2', kind: 'helper', title: '创作者小助手', subtitle: `亲爱的${CURRENT_USER.name}：你的上周创作周报（05·04 至 05⋯`, time: '02:29', badge: '57', bg: '#7E6BD9', icon: 'person' },
  { id: 't3', kind: 'helper', title: '知乎圈子助手', subtitle: '#古法编程 活动收官在即，我们看到了大家在⋯', time: '00:20', badge: '99+', bg: '#1FA38C', icon: 'circle' },
  { id: 't4', kind: 'helper', title: '官方账号消息', subtitle: '您好，我们已收到您的个人认证申请。经确认，您提⋯', time: '05-08', mute: true, bg: '#1A75E0', icon: 'inbox' },
  { id: 't5', kind: 'helper', title: '知乎活动助手', subtitle: '特邀你用 AI，一起重塑知乎的每一次问答体验⋯', time: '04-24', badge: '8', bg: '#E08A3A', icon: 'bulb' },
  { id: 't6', kind: 'helper', title: '订阅更新助手', subtitle: '哇，你关注的 Mercer 斩获了这份荣誉！快去看看⋯', time: '04-22', bg: '#8E6BD9', icon: 'bookmark' },
  { id: 't7', kind: 'helper', title: '用研小助手', subtitle: '亲爱的知友：你好，这是一份关于产品使用习惯⋯', time: '04-15', badge: '2', bg: '#3D4A5E', icon: 'scroll' },
];

// ---------- Top component ----------
function MessagesPage({ onBack, onDirectTap, onSubPage, onProfileTap, onPlusTap }) {
  return (
    <div style={{
      position: 'absolute', inset: 0, background: M_BG,
      color: M_TEXT, display: 'flex', flexDirection: 'column',
      fontFamily: '"PingFang SC", "Noto Sans SC", -apple-system, system-ui',
    }}>
      <div style={{ height: 38, flexShrink: 0 }}/>

      <div style={{
        position: 'relative', flexShrink: 0,
        padding: '8px 14px', display: 'flex', alignItems: 'center',
      }}>
        <div style={{ flex: 1, textAlign: 'center', fontSize: 14, fontWeight: 600 }}>消息</div>
        <div style={{ position: 'absolute', right: 14, display: 'flex', gap: 12 }}>
          <MIcon d="M6 4 h12 v4 h2 v3 h-2 v9 h-12 v-9 h-2 v-3 h2z M9 7 h6 M9 11 h6"/>
          <MIcon d="M12 4 a4 4 0 014 4 a4 4 0 11-8 0 a4 4 0 014 -4 z M4 21 a8 8 0 0116 0 M17 6 v4 M15 8 h4"/>
        </div>
      </div>

      {/* Notification banner */}
      <div style={{
        margin: '4px 12px 8px', flexShrink: 0,
        background: '#16191F', borderRadius: 8,
        padding: '8px 12px', display: 'flex', alignItems: 'center', gap: 8,
      }}>
        <div style={{ position: 'relative' }}>
          <MIcon w={14} d="M12 3 a6 6 0 016 6 v4 l1.5 2 h-15 L4 13 V9 a6 6 0 016-6 z M10 19 a2 2 0 004 0"/>
          <span style={{
            position: 'absolute', top: -2, right: -2,
            width: 6, height: 6, borderRadius: 3, background: M_RED,
          }}/>
        </div>
        <span style={{ flex: 1, fontSize: 10, color: M_TEXT }}>开启系统通知，及时收到互动推送</span>
        <span style={{ fontSize: 10, color: M_BLUE }}>去开启</span>
        <span style={{ fontSize: 12, color: M_MUTED, cursor: 'pointer' }}>×</span>
      </div>

      {/* Body scrollable */}
      <div style={{ flex: 1, overflowY: 'auto' }}>
        {/* 4 category icons */}
        <div style={{
          display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)',
          padding: '6px 8px 12px',
        }}>
          {M_CATEGORIES.map(c => (
            <div key={c.id} onClick={() => onSubPage(c.id)} style={{
              display: 'flex', flexDirection: 'column', alignItems: 'center',
              gap: 6, cursor: 'pointer',
            }}>
              <CategoryIcon kind={c.icon}/>
              <span style={{ fontSize: 11, color: M_TEXT }}>{c.label}</span>
            </div>
          ))}
        </div>

        {/* Threads */}
        {M_THREADS.map((t, i) => (
          <ThreadRow key={t.id} t={t} divider={i > 0}/>
        ))}
        <div style={{ height: 20 }}/>
      </div>

      <BottomNav onBack={onBack} onDirectTap={onDirectTap} onProfileTap={onProfileTap} onPlusTap={onPlusTap} activeTab="msg"/>
    </div>
  );
}

function MIcon({ d, w = 18, sw = 1.5, stroke = M_TEXT, fill = 'none' }) {
  return (
    <svg width={w} height={w} viewBox="0 0 24 24" fill={fill} stroke={stroke}
         strokeWidth={sw} strokeLinecap="round" strokeLinejoin="round">
      <path d={d}/>
    </svg>
  );
}

function CategoryIcon({ kind }) {
  const sz = 30;
  const sw = 1.6;
  if (kind === 'bubble') return (
    <svg width={sz} height={sz} viewBox="0 0 32 32" fill="none" stroke={M_TEXT} strokeWidth={sw} strokeLinecap="round" strokeLinejoin="round">
      <path d="M6 9 a3 3 0 013-3 h14 a3 3 0 013 3 v8 a3 3 0 01-3 3 h-8 l-5 4 v-4 H9 a3 3 0 01-3 -3 z"/>
      <circle cx="13" cy="13.5" r="1" fill={M_TEXT} stroke="none"/>
      <circle cx="19" cy="13.5" r="1" fill={M_TEXT} stroke="none"/>
    </svg>
  );
  if (kind === 'heart') return (
    <svg width={sz} height={sz} viewBox="0 0 32 32" fill="none" stroke={M_TEXT} strokeWidth={sw} strokeLinecap="round" strokeLinejoin="round">
      <path d="M16 26 C 4 18, 6 7, 13 7 c 2 0 3 1 3 3 c 0 -2 1 -3 3 -3 c 7 0 9 11 -3 19 z"/>
      <path d="M14 16 l2 2 l4 -4" strokeWidth="1.4"/>
    </svg>
  );
  if (kind === 'star') return (
    <svg width={sz} height={sz} viewBox="0 0 32 32" fill="none" stroke={M_TEXT} strokeWidth={sw} strokeLinecap="round" strokeLinejoin="round">
      <path d="M16 5 L19.5 12 L27 13.5 L21.5 19 L23 27 L16 23 L9 27 L10.5 19 L5 13.5 L12.5 12 Z"/>
    </svg>
  );
  if (kind === 'eye') return (
    <svg width={sz} height={sz} viewBox="0 0 32 32" fill="none" stroke={M_TEXT} strokeWidth={sw} strokeLinecap="round" strokeLinejoin="round">
      <circle cx="16" cy="16" r="11"/>
      <circle cx="16" cy="16" r="2" fill={M_TEXT} stroke="none"/>
    </svg>
  );
  return null;
}

function ThreadRow({ t, divider }) {
  return (
    <div style={{
      display: 'flex', gap: 11, padding: '10px 14px',
      borderTop: divider ? `1px solid ${M_DIVIDER}` : 'none',
      alignItems: 'center',
    }}>
      <div style={{
        width: 34, height: 34, borderRadius: 17, flexShrink: 0,
        background: t.bg, display: 'flex', alignItems: 'center', justifyContent: 'center',
        color: '#fff',
      }}>
        <ThreadIcon kind={t.icon || 'doc'}/>
      </div>
      <div style={{ flex: 1, minWidth: 0 }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 4, fontSize: 12, fontWeight: 600, color: M_TEXT }}>
          <span>{t.title}</span>
          {t.mute && <MIcon w={10} sw={1.3} stroke={M_MUTED} d="M5 5 l14 14 M9 6 a3 3 0 016 0 v4 M5 11 v1 a7 7 0 0010 5"/>}
        </div>
        <div style={{
          fontSize: 10.5, color: M_MUTED, marginTop: 3,
          overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',
        }}>{t.subtitle}</div>
      </div>
      {t.time && <div style={{ fontSize: 9.5, color: M_MUTED, alignSelf: 'flex-start', marginTop: 2 }}>{t.time}</div>}
      {t.badge && (
        <div style={{
          background: M_RED, color: '#fff', fontSize: 8.5,
          padding: '0 4px', borderRadius: 8, height: 13, lineHeight: '13px',
          minWidth: 16, textAlign: 'center', fontWeight: 600,
          alignSelf: 'flex-start', marginTop: 18,
        }}>{t.badge}</div>
      )}
    </div>
  );
}

function ThreadIcon({ kind }) {
  const stroke = '#fff';
  if (kind === 'q')        return <MIcon w={16} stroke={stroke} d="M9 9 a3 3 0 116 0 c0 2 -3 2 -3 5 M12 17 v0.5"/>;
  if (kind === 'person')   return <MIcon w={16} stroke={stroke} d="M12 5 a3.5 3.5 0 110 7 a3.5 3.5 0 010 -7 M5 21 a7 7 0 0114 0"/>;
  if (kind === 'circle')   return <MIcon w={16} stroke={stroke} d="M5 12 a7 7 0 1014 0 a7 7 0 00-14 0 M12 8 a4 4 0 014 4"/>;
  if (kind === 'inbox')    return <MIcon w={16} stroke={stroke} d="M4 13 v6 h16 v-6 l-3 -7 h-10 z M4 13 h6 l1 2 h2 l1 -2 h6"/>;
  if (kind === 'bulb')     return <MIcon w={16} stroke={stroke} d="M9 17 v2 h6 v-2 M8 15 a6 6 0 118 0 v2 h-8 z"/>;
  if (kind === 'bookmark') return <MIcon w={16} stroke={stroke} d="M7 4 h10 v17 l-5 -3 l-5 3 z M12 9 v6 M9 12 h6"/>;
  if (kind === 'scroll')   return <MIcon w={16} stroke={stroke} d="M6 4 h11 a2 2 0 012 2 v13 a3 3 0 01-3 3 h-9 a2 2 0 01-2 -2 V6 a2 2 0 012-2 z M9 9 h6 M9 13 h6"/>;
  /* default doc */        return <MIcon w={16} stroke={stroke} d="M7 4 h7 l4 4 v11 a2 2 0 01-2 2 h-9 a2 2 0 01-2 -2 V6 a2 2 0 012-2 z M14 4 v4 h4"/>;
}

// ---------- Sub-page ----------
function MessageSubPage({ catId, onBack }) {
  const cat = M_CATEGORIES.find(c => c.id === catId);
  const [tab, setTab] = React.useState('past'); // past | mirror
  return (
    <div style={{
      position: 'absolute', inset: 0, background: M_BG,
      color: M_TEXT, display: 'flex', flexDirection: 'column',
      fontFamily: '"PingFang SC", "Noto Sans SC", -apple-system, system-ui',
    }}>
      <div style={{ height: 38, flexShrink: 0 }}/>
      <div style={{
        position: 'relative', flexShrink: 0,
        padding: '6px 14px', display: 'flex', alignItems: 'center',
      }}>
        <span onClick={onBack} style={{ cursor: 'pointer', position: 'absolute', left: 14 }}>
          <MIcon d="M15 5 L8 12 L15 19" sw={1.8} w={16}/>
        </span>
        <div style={{ flex: 1, textAlign: 'center', fontSize: 13, fontWeight: 600 }}>{cat.label}</div>
        <div style={{ position: 'absolute', right: 14, fontSize: 13, letterSpacing: 1 }}>⋯</div>
      </div>

      {catId === 'like' && (
        <div style={{
          margin: '4px 12px 6px', padding: '8px 11px',
          background: '#15171C', borderRadius: 6,
          display: 'flex', alignItems: 'center', flexShrink: 0,
          fontSize: 10.5, color: M_TEXT,
        }}>
          <span style={{ flex: 1 }}>查看全部感谢</span>
          <span style={{ color: M_MUTED }}>›</span>
        </div>
      )}

      {/* Tab row: 以往 | 镜像回答 */}
      <div style={{
        padding: '6px 14px 10px', flexShrink: 0,
        display: 'flex', alignItems: 'flex-end', gap: 18,
      }}>
        <TabLabel label="以往" active={tab === 'past'} onClick={() => setTab('past')}/>
        <TabLabel label="镜像回答" mirror active={tab === 'mirror'} onClick={() => setTab('mirror')}/>
      </div>

      <div style={{ flex: 1, overflowY: 'auto' }}>
        {tab === 'past'   && <PastList   catId={catId}/>}
        {tab === 'mirror' && <MirrorList catId={catId}/>}
        <div style={{ height: 16 }}/>
      </div>
    </div>
  );
}

function TabLabel({ label, mirror, active, onClick }) {
  return (
    <div onClick={onClick} style={{
      cursor: 'pointer', position: 'relative', paddingBottom: 4,
      fontSize: active ? 13 : 11,
      fontWeight: active ? 700 : 500,
      color: active ? M_TEXT : '#5C636B',
      letterSpacing: 0.3,
      transition: 'font-size 0.15s',
    }}>
      {label}
      {active && (
        <div style={{
          position: 'absolute', left: '50%', transform: 'translateX(-50%)',
          bottom: -2, width: mirror ? 22 : 16, height: 2.5, borderRadius: 1.5,
          background: mirror ? '#7C6BFF' : M_BLUE,
        }}/>
      )}
    </div>
  );
}

// ---------- Past / Mirror lists (per category) ----------
// 用 mock-user.jsx 的随机生成器一次性出 8 个数组. 这样:
// - 不暴露任何特定真实事件 / 真人名字
// - 每次浏览器刷新看到的都是不同内容 (验证下游是否真的用了 CURRENT_USER)
const _MSGS = (typeof generateMockMessageLists === 'function')
  ? generateMockMessageLists()
  : { pastCmt: [], mirrorCmt: [], pastLike: [], mirrorLike: [], pastFav: [], mirrorFav: [], pastSub: [], mirrorSub: [] };

const PAST_CMT    = _MSGS.pastCmt;
const MIRROR_CMT  = _MSGS.mirrorCmt;
const PAST_LIKE   = _MSGS.pastLike;
const MIRROR_LIKE = _MSGS.mirrorLike;
const PAST_FAV    = _MSGS.pastFav;
const MIRROR_FAV  = _MSGS.mirrorFav;
const PAST_SUB    = _MSGS.pastSub;
const MIRROR_SUB  = _MSGS.mirrorSub;

function PastList({ catId }) {
  if (catId === 'cmt')  return <CommentList items={PAST_CMT}/>;
  if (catId === 'like') return <LikeList items={PAST_LIKE}/>;
  if (catId === 'fav')  return <FavList items={PAST_FAV}/>;
  if (catId === 'sub')  return <SubList items={PAST_SUB}/>;
  return null;
}
function MirrorList({ catId }) {
  if (catId === 'cmt')  return <CommentList items={MIRROR_CMT} mirror/>;
  if (catId === 'like') return <LikeList items={MIRROR_LIKE} mirror/>;
  if (catId === 'fav')  return <FavList items={MIRROR_FAV} mirror/>;
  if (catId === 'sub')  return <SubList items={MIRROR_SUB} mirror/>;
  return null;
}

function Avatar({ color, mirror }) {
  return (
    <div style={{
      width: 24, height: 24, borderRadius: 12, flexShrink: 0,
      background: mirror
        ? `linear-gradient(135deg, ${color}, #2A2050)`
        : `linear-gradient(135deg, ${color}, ${color}aa)`,
      border: mirror ? '1.5px solid #7C6BFF' : 'none',
    }}/>
  );
}

function CommentList({ items, mirror }) {
  return (
    <div>
      {items.map((it, i) => (
        <div key={i} style={{ padding: '12px 14px 14px', borderBottom: `1px solid ${M_DIVIDER}` }}>
          <div style={{ display: 'flex', gap: 10 }}>
            <Avatar color={it.avatar} mirror={mirror}/>
            <div style={{ flex: 1, minWidth: 0 }}>
              <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
                <span style={{ fontSize: 10.5, fontWeight: 600 }}>{it.name}</span>
                <span style={{ fontSize: 9, color: M_MUTED }}>{it.date}</span>
                <div style={{ flex: 1 }}/>
                <span style={{ fontSize: 11, color: M_MUTED, letterSpacing: 1 }}>⋯</span>
              </div>
              <div style={{ fontSize: 10, color: M_TEXT, marginTop: 5, lineHeight: 1.5 }}>
                {it.head}
                {it.headTag && (
                  <span style={{
                    fontSize: 8, padding: '1px 4px', borderRadius: 3,
                    background: '#2C2F36', color: '#9097A0', marginLeft: 3,
                  }}>{it.headTag}</span>
                )}
              </div>
              <div style={{ fontSize: 10, color: M_TEXT, marginTop: 5, lineHeight: 1.5 }}>{it.body}</div>

              <div style={{
                marginTop: 7, padding: '7px 9px', background: '#14171D', borderRadius: 6,
                display: 'flex', alignItems: 'center', gap: 7,
              }}>
                <div style={{ flex: 1, minWidth: 0 }}>
                  <div style={{ fontSize: 9.5, color: M_TEXT, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{it.qTitle}</div>
                  <div style={{ fontSize: 8.5, color: M_MUTED, marginTop: 3 }}>{it.stats}</div>
                </div>
                {it.thumb && <div style={{
                  width: 38, height: 30, borderRadius: 3,
                  background: 'linear-gradient(135deg, #3B2D1F, #1F1812)',
                }}/>}
              </div>

              <div style={{ display: 'flex', justifyContent: 'flex-end', gap: 8, marginTop: 8 }}>
                <PillBtn>
                  <MIcon w={11} sw={1.4} stroke={M_TEXT} d="M12 20 C 2 12 4 4 9 4 c 1.5 0 2.5 1 3 2.5 c 0.5 -1.5 1.5 -2.5 3 -2.5 c 5 0 7 8 -3 16 z"/>
                </PillBtn>
                <PillBtn>
                  <MIcon w={11} sw={1.4} stroke={M_TEXT} d="M5 5 a2 2 0 012-2 h10 a2 2 0 012 2 v9 a2 2 0 01-2 2 h-5 l-4 4 v-4 H7 a2 2 0 01-2 -2 z"/>
                  <span style={{ width: 1, height: 10, background: '#3A3E45', margin: '0 4px' }}/>
                  <span style={{ fontSize: 11 }}>🥲</span>
                </PillBtn>
              </div>
            </div>
          </div>
        </div>
      ))}
    </div>
  );
}

function LikeList({ items, mirror }) {
  return (
    <div>
      {items.map((it, i) => (
        <div key={i} style={{ padding: '10px 14px 11px', borderBottom: `1px solid ${M_DIVIDER}` }}>
          <div style={{ display: 'flex', gap: 9 }}>
            <Avatar color={it.avatar} mirror={mirror}/>
            <div style={{ flex: 1, minWidth: 0 }}>
              <div style={{ display: 'flex', alignItems: 'center', gap: 7 }}>
                <span style={{ fontSize: 10.5, fontWeight: 600 }}>{it.name}</span>
                <span style={{ fontSize: 9, color: M_MUTED }}>{it.date}</span>
              </div>
              <div style={{ fontSize: 10, color: M_TEXT, marginTop: 5 }}>{it.body}</div>
              <div style={{
                marginTop: 7, padding: '7px 9px', background: '#14171D', borderRadius: 6,
                display: 'flex', alignItems: 'center', gap: 7,
              }}>
                <div style={{ flex: 1, minWidth: 0 }}>
                  <div style={{ fontSize: 9.5, color: M_TEXT, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{it.qTitle}</div>
                  <div style={{ fontSize: 8.5, color: M_MUTED, marginTop: 3 }}>{it.stats}</div>
                </div>
                {it.thumb && <div style={{
                  width: 32, height: 26, borderRadius: 3,
                  background: 'linear-gradient(135deg, #C8B8A0, #6A4A30)',
                }}/>}
              </div>
              <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: 7 }}>
                <PillBtn><span style={{ fontSize: 10 }}>🥲</span><span style={{ fontSize: 9, color: M_TEXT, marginLeft: 3 }}>{it.thanksBtn}</span></PillBtn>
              </div>
            </div>
          </div>
        </div>
      ))}
    </div>
  );
}

function FavList({ items, mirror }) {
  return (
    <div>
      {items.map((it, i) => (
        <div key={i} style={{ padding: '10px 14px 11px', borderBottom: `1px solid ${M_DIVIDER}` }}>
          <div style={{ display: 'flex', gap: 9 }}>
            <Avatar color="#5BA3E0" mirror={mirror}/>
            <div style={{ flex: 1, minWidth: 0 }}>
              <div style={{ display: 'flex', alignItems: 'center', gap: 7 }}>
                <span style={{ fontSize: 10.5, fontWeight: 600 }}>{it.name}</span>
                <span style={{ fontSize: 9, color: M_MUTED }}>{it.date}</span>
              </div>
              <div style={{ fontSize: 10, color: M_TEXT, marginTop: 5 }}>{it.body}</div>
              <div style={{
                marginTop: 6, padding: '0',
                display: 'flex', alignItems: 'center', gap: 7,
              }}>
                <div style={{ flex: 1, minWidth: 0 }}>
                  <div style={{ fontSize: 9.5, color: '#C8CCD2', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{it.qTitle}</div>
                  <div style={{ fontSize: 8.5, color: M_MUTED, marginTop: 3 }}>{it.stats}</div>
                </div>
                {it.thumb && <div style={{
                  width: 32, height: 26, borderRadius: 3,
                  background: 'linear-gradient(135deg, #C8B8A0, #6A4A30)',
                }}/>}
              </div>
            </div>
          </div>
        </div>
      ))}
    </div>
  );
}

function SubList({ items, mirror }) {
  return (
    <div>
      {items.map((it, i) => (
        <div key={i} style={{
          display: 'flex', alignItems: 'center', gap: 9,
          padding: '9px 14px', borderBottom: `1px solid ${M_DIVIDER}`,
        }}>
          <Avatar color={mirror ? '#7C6BFF' : '#5BA3E0'} mirror={mirror}/>
          <div style={{ flex: 1, minWidth: 0 }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
              <span style={{ fontSize: 10.5, fontWeight: 600 }}>{it.name}</span>
              {it.verified && (
                <svg width="9" height="9" viewBox="0 0 12 12">
                  <circle cx="6" cy="6" r="6" fill={M_BLUE}/>
                  <path d="M3.5 6 L5.2 7.6 L8.5 4.3" stroke="#fff" strokeWidth="1.4" fill="none" strokeLinecap="round" strokeLinejoin="round"/>
                </svg>
              )}
              <span style={{ fontSize: 10, color: M_TEXT }}>关注了你</span>
            </div>
            {it.subline && <div style={{ fontSize: 9, color: M_MUTED, marginTop: 2, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{it.subline}</div>}
            <div style={{ fontSize: 9, color: M_MUTED, marginTop: 2 }}>{it.date}</div>
          </div>
          <div style={{
            padding: '4px 9px', borderRadius: 4,
            background: M_BLUE_DIM, color: '#8EB8EE',
            fontSize: 9.5, fontWeight: 600, flexShrink: 0,
            display: 'flex', alignItems: 'center', gap: 3,
          }}>
            {it.followAction === '回关' || it.followAction === '回订阅' ? '↩' : '+'}
            <span>{it.followAction}</span>
          </div>
        </div>
      ))}
    </div>
  );
}

function PillBtn({ children }) {
  return (
    <div style={{
      display: 'flex', alignItems: 'center',
      background: '#1C1F25', borderRadius: 14,
      padding: '4px 10px', cursor: 'pointer',
    }}>{children}</div>
  );
}

Object.assign(window, { MessagesPage, MessageSubPage });
