// ============================================================
// Alumnus partner portal — mobile-first responsive web
// Screens 2.1 → 2.8 (Maria Reyes, mother of Anna)
// ============================================================
const { Icon: PI, Crest: PC, Avatar: PA, Button: PB, Eyebrow: PE,
        Pill: PP, Sparkline: PSp, MEMBER: MM, PARTNER: PP_USER, SPONSOR: PS } = window.AL;

// ─────────────────────────────────────────────────────────────
// Shared partner-portal chrome: top bar + side rail (web app)
// ─────────────────────────────────────────────────────────────
const PartnerShell = ({ children, active = 'overview', alertOpen = false }) => {
  const nav = [
    { k: 'overview', i: 'house-line',   l: 'Overview' },
    { k: 'timeline', i: 'list-bullets', l: 'Timeline' },
    { k: 'alerts',   i: 'bell-simple',  l: 'Alerts', badge: alertOpen ? 1 : 0 },
    { k: 'message',  i: 'chat-circle',  l: 'Message' },
    { k: 'learn',    i: 'book-open',    l: 'Learn' },
    { k: 'profile',  i: 'user',         l: 'You' },
  ];
  return (
    <div style={{ display: 'flex', flexDirection: 'column', height: '100%',
                  background: 'var(--bg-page)', fontFamily: 'var(--font-body)', color: 'var(--fg-primary)' }}>
      {/* top bar */}
      <div style={{
        display: 'flex', alignItems: 'center', justifyContent: 'space-between',
        padding: '14px 22px', borderBottom: '1px solid var(--border-hairline)',
        background: 'var(--bg-page)',
      }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
          <PC size={18}/>
          <span style={{ fontFamily: 'var(--font-display)', fontSize: 14,
                         letterSpacing: '0.22em', fontWeight: 500, textTransform: 'uppercase' }}>
            Alumnus
          </span>
          <span style={{ fontSize: 11, color: 'var(--fg-tertiary)',
                         letterSpacing: '0.04em', textTransform: 'uppercase',
                         marginLeft: 6, paddingLeft: 12, borderLeft: '1px solid var(--border-hairline)' }}>
            Network · Maria
          </span>
        </div>
        <div style={{ display: 'flex', alignItems: 'center', gap: 14 }}>
          <PI name="bell-simple" size={18} color="var(--color-stone)"/>
          <PA initials="MR" size={28} tone="oat"/>
        </div>
      </div>

      {/* content */}
      <div style={{ flex: 1, overflow: 'auto' }}>{children}</div>

      {/* bottom nav (mobile-first) */}
      <div style={{
        display: 'flex', borderTop: '1px solid var(--border-hairline)', background: 'var(--bg-page)',
      }}>
        {nav.map(n => {
          const on = n.k === active;
          return (
            <div key={n.k} style={{
              flex: 1, padding: '10px 0 12px', display: 'flex', flexDirection: 'column',
              alignItems: 'center', gap: 4, position: 'relative',
              color: on ? 'var(--color-ivy)' : 'var(--color-stone)',
            }}>
              <PI name={n.i} size={20} weight={on ? 'fill' : 'regular'}/>
              <span style={{ fontSize: 10, fontWeight: 500 }}>{n.l}</span>
              {n.badge > 0 && (
                <span style={{
                  position: 'absolute', top: 6, right: '50%', marginRight: -16,
                  width: 8, height: 8, borderRadius: 999, background: 'var(--color-ember)',
                }}/>
              )}
            </div>
          );
        })}
      </div>
    </div>
  );
};

// ─────────────────────────────────────────────────────────────
// 2.1  Partner Onboarding / Pairing
// ─────────────────────────────────────────────────────────────
const P_Onboard = () => (
  <div style={{ background: 'var(--bg-page)', height: '100%', overflow: 'auto',
                fontFamily: 'var(--font-body)', color: 'var(--fg-primary)' }}>
    <div style={{ padding: '56px 28px 40px', display: 'flex', flexDirection: 'column',
                  minHeight: '100%', boxSizing: 'border-box' }}>
      <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', marginBottom: 36 }}>
        <PC size={36}/>
      </div>

      <PE tone="brass" style={{ marginBottom: 12, textAlign: 'center' }}>An invitation</PE>
      <h1 style={{ fontFamily: 'var(--font-display)', fontSize: 30, lineHeight: '36px',
                   fontWeight: 400, letterSpacing: '-0.012em', margin: '0 0 18px', textAlign: 'center' }}>
        Anna asked you to be in her network.
      </h1>
      <p style={{ fontSize: 15, lineHeight: '22px', color: 'var(--fg-secondary)',
                  margin: '0 0 32px', textAlign: 'center' }}>
        You're being trusted to look out for one of Pine Tree Recovery's graduates. Here is what you will and won't see.
      </p>

      <div style={{ background: 'var(--bg-surface)', border: '1px solid var(--border-hairline)',
                    borderRadius: 4, padding: '20px 22px', marginBottom: 22 }}>
        {[
          { ok: true,  l: 'Anna\'s overall rhythm', d: 'How her week is tracking — steady, mixed, or off.' },
          { ok: true,  l: 'Meeting attendance',     d: 'When she gets to her meetings. Not what is said in them.' },
          { ok: true,  l: 'Clear, calm alerts',     d: 'A note when a pattern is worth a conversation. Never an alarm.' },
          { ok: false, l: 'Messages, browsing, or location history', d: "You will never see contents. Only patterns." },
          { ok: false, l: 'A risk score number',   d: 'We don\'t show you numbers. We use plain English.' },
        ].map((r, i, arr) => (
          <div key={i} style={{
            display: 'flex', gap: 14, padding: '12px 0',
            borderBottom: i < arr.length - 1 ? '1px solid var(--border-hairline)' : 'none',
          }}>
            <PI name={r.ok ? 'check-circle' : 'x-circle'} size={20}
                color={r.ok ? 'var(--color-moss)' : 'var(--color-stone)'} style={{ marginTop: 2 }}/>
            <div style={{ flex: 1 }}>
              <div style={{ fontSize: 13.5, fontWeight: 600 }}>{r.l}</div>
              <div style={{ fontSize: 12, color: 'var(--fg-tertiary)' }}>{r.d}</div>
            </div>
          </div>
        ))}
      </div>

      <div style={{ fontSize: 12, color: 'var(--fg-tertiary)', marginBottom: 22,
                    fontFamily: 'var(--font-display)', fontStyle: 'italic', textAlign: 'center' }}>
        By accepting you agree to the partner compact. Anna can remove you at any time.
      </div>

      <div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginTop: 'auto' }}>
        <PB variant="primary" full size="lg">Accept · I'll look out for Anna</PB>
        <PB variant="quiet" full>Not the right time</PB>
      </div>
    </div>
  </div>
);

// ─────────────────────────────────────────────────────────────
// 2.2  Member Overview (Partner Home)
// ─────────────────────────────────────────────────────────────
const P_Overview = ({ alertOpen = false }) => (
  <PartnerShell active="overview" alertOpen={alertOpen}>
    <div style={{ padding: '24px 22px 40px' }}>
      {/* Member identity */}
      <div style={{ display: 'flex', alignItems: 'center', gap: 14, marginBottom: 22 }}>
        <PA initials="AR" tone="brass" size={56}/>
        <div style={{ flex: 1, minWidth: 0 }}>
          <div style={{ fontFamily: 'var(--font-display)', fontSize: 22, fontWeight: 400,
                        letterSpacing: '-0.008em' }}>Anna</div>
          <div style={{ fontSize: 11.5, color: 'var(--fg-tertiary)',
                        letterSpacing: '0.04em', textTransform: 'uppercase' }}>
            Class of 2026 · day {alertOpen ? 45 : 30}
          </div>
        </div>
      </div>

      {/* Status hero */}
      <div style={{
        background: alertOpen ? 'var(--bg-elevated)' : 'var(--color-ivy)',
        color: alertOpen ? 'var(--fg-primary)' : 'var(--color-bone)',
        borderRadius: 4, padding: '22px 22px',
        border: alertOpen ? '1px solid var(--color-ember-soft)' : 'none',
        marginBottom: 18,
        borderLeft: alertOpen ? '3px solid var(--color-ember)' : undefined,
      }}>
        <div style={{ fontSize: 10.5, letterSpacing: '0.1em', textTransform: 'uppercase',
                      fontWeight: 600, marginBottom: 10,
                      color: alertOpen ? 'var(--color-ember)' : 'var(--color-brass-soft)' }}>
          {alertOpen ? 'A pattern worth a conversation' : 'Where she is'}
        </div>
        <div style={{ fontFamily: 'var(--font-display)', fontSize: 20, lineHeight: '28px',
                      fontWeight: 400, letterSpacing: '-0.008em', marginBottom: 12 }}>
          {alertOpen
            ? "Anna's rhythm shifted this week. Sleep is later, two meetings missed. Nothing has happened. She knows you are seeing this."
            : "Anna is doing steady this week. Sleep is back on rhythm, meetings full, check-ins on time."}
        </div>
        {alertOpen && (
          <div style={{ display: 'flex', gap: 8, marginTop: 14 }}>
            <PB variant="brass" size="sm">See what we noticed</PB>
            <PB variant="ghost" size="sm" style={{ borderColor: 'var(--border-hairline)' }}>Call Anna</PB>
          </div>
        )}
      </div>

      {/* This week summary */}
      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 1,
                    background: 'var(--border-hairline)',
                    border: '1px solid var(--border-hairline)', borderRadius: 4,
                    overflow: 'hidden', marginBottom: 22 }}>
        {[
          { n: alertOpen ? '4' : '6', d: 'of 6', l: 'Meetings' },
          { n: alertOpen ? '5' : '7', d: 'of 7', l: 'Check-ins' },
          { n: alertOpen ? '4' : '7', d: 'nights', l: 'Steady sleep' },
        ].map((s, i) => (
          <div key={i} style={{ background: 'var(--bg-surface)', padding: '14px 14px' }}>
            <div style={{ display: 'flex', alignItems: 'baseline', gap: 4, marginBottom: 4 }}>
              <span style={{ fontFamily: 'var(--font-display)', fontSize: 26, fontWeight: 500,
                             color: alertOpen && i < 2 ? 'var(--color-ember)' : 'var(--color-ivy)' }}>{s.n}</span>
              <span style={{ fontSize: 12, color: 'var(--fg-tertiary)' }}>{s.d}</span>
            </div>
            <div style={{ fontSize: 11, color: 'var(--fg-tertiary)', letterSpacing: '0.04em',
                          textTransform: 'uppercase', fontWeight: 500 }}>{s.l}</div>
          </div>
        ))}
      </div>

      <PE style={{ marginBottom: 12 }}>What you can do</PE>
      <div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginBottom: 22 }}>
        {[
          { i: 'chat-circle', l: 'Send Anna a note',         d: 'A short message. Suggested phrases ready.' },
          { i: 'phone',       l: 'Call her',                  d: 'She usually answers in the evening.' },
          { i: 'list-bullets',l: 'See her full timeline',     d: 'The last 30 days, in plain language.' },
        ].map((a, i) => (
          <div key={i} style={{
            display: 'flex', alignItems: 'center', gap: 14,
            padding: '12px 16px', background: 'var(--bg-surface)',
            border: '1px solid var(--border-hairline)', borderRadius: 4,
          }}>
            <div style={{
              width: 36, height: 36, borderRadius: 999, background: 'var(--color-bone)',
              display: 'flex', alignItems: 'center', justifyContent: 'center',
            }}><PI name={a.i} size={18} color="var(--color-ivy)"/></div>
            <div style={{ flex: 1, minWidth: 0 }}>
              <div style={{ fontSize: 14, fontWeight: 500 }}>{a.l}</div>
              <div style={{ fontSize: 12, color: 'var(--fg-tertiary)' }}>{a.d}</div>
            </div>
            <PI name="caret-right" size={14} color="var(--color-stone-soft)"/>
          </div>
        ))}
      </div>

      <div style={{ fontSize: 11, color: 'var(--fg-tertiary)', textAlign: 'center',
                    fontFamily: 'var(--font-display)', fontStyle: 'italic' }}>
        Updated 12 minutes ago · You see patterns, never contents.
      </div>
    </div>
  </PartnerShell>
);

// ─────────────────────────────────────────────────────────────
// 2.3  Activity Timeline
// ─────────────────────────────────────────────────────────────
const P_Timeline = () => {
  const days = [
    { d: 'Wednesday', date: 'May 14', items: [
      { i: 'moon-stars',  l: 'Sleep started later than usual — 1:40 am.', tone: 'brass' },
      { i: 'calendar-x',  l: "Did not attend St. Margaret's evening group.", tone: 'brass' },
      { i: 'notebook',    l: 'Did her morning check-in.', tone: 'moss' },
    ]},
    { d: 'Tuesday', date: 'May 13', items: [
      { i: 'check-circle',l: 'Attended Pine Tree IOP.', tone: 'moss' },
      { i: 'chat-circle', l: 'Reached out to Beth — short call.', tone: 'moss' },
      { i: 'notebook',    l: 'Check-in: "mixed".', tone: 'oat' },
    ]},
    { d: 'Monday', date: 'May 12', items: [
      { i: 'check-circle',l: 'Attended Pine Tree IOP.', tone: 'moss' },
      { i: 'moon-stars',  l: 'Steady sleep — 7h 20m.', tone: 'moss' },
      { i: 'notebook',    l: 'Check-in: "light".', tone: 'moss' },
    ]},
    { d: 'Sunday', date: 'May 11', items: [
      { i: 'check-circle',l: 'Attended Sunday women.', tone: 'moss' },
      { i: 'notebook',    l: 'Check-in: "light".', tone: 'moss' },
    ]},
  ];
  const tones = {
    moss: { bg: 'rgba(79,106,74,0.14)', fg: 'var(--color-moss)' },
    brass:{ bg: 'rgba(168,132,60,0.16)', fg: 'var(--color-brass-dark)' },
    oat:  { bg: 'var(--color-oat)', fg: 'var(--fg-secondary)' },
  };
  return (
    <PartnerShell active="timeline">
      <div style={{ padding: '22px 22px 40px' }}>
        <PE style={{ marginBottom: 6 }}>Timeline · Anna</PE>
        <h1 style={{ fontFamily: 'var(--font-display)', fontSize: 24, fontWeight: 400,
                     letterSpacing: '-0.012em', margin: '0 0 16px' }}>
          What we've seen this week.
        </h1>

        <div style={{ display: 'flex', gap: 4, marginBottom: 18,
                      padding: 3, background: 'var(--color-oat)', borderRadius: 999, width: 'fit-content' }}>
          {['Week', 'Month', 'All'].map((t, i) => (
            <div key={t} style={{
              padding: '5px 12px', borderRadius: 999, fontSize: 12, fontWeight: 500,
              background: i === 0 ? 'var(--color-bone)' : 'transparent',
              color: i === 0 ? 'var(--fg-primary)' : 'var(--fg-tertiary)',
            }}>{t}</div>
          ))}
        </div>

        {days.map((day, di) => (
          <div key={di} style={{ marginBottom: 24 }}>
            <div style={{ display: 'flex', alignItems: 'baseline', gap: 8, marginBottom: 10 }}>
              <span style={{ fontFamily: 'var(--font-display)', fontSize: 18, fontWeight: 500 }}>{day.d}</span>
              <span style={{ fontSize: 11, color: 'var(--fg-tertiary)',
                             letterSpacing: '0.04em', textTransform: 'uppercase' }}>{day.date}</span>
            </div>
            <div style={{ position: 'relative', paddingLeft: 14,
                          borderLeft: '1px solid var(--border-hairline)' }}>
              {day.items.map((it, ii) => {
                const t = tones[it.tone];
                return (
                  <div key={ii} style={{
                    display: 'flex', gap: 12, paddingBottom: 12, position: 'relative',
                  }}>
                    <div style={{
                      position: 'absolute', left: -20, top: 2,
                      width: 13, height: 13, borderRadius: 999,
                      background: t.bg, border: `2px solid var(--bg-page)`,
                    }}>
                      <div style={{ width: 5, height: 5, borderRadius: 999, background: t.fg,
                                    position: 'absolute', top: 2, left: 2 }}/>
                    </div>
                    <PI name={it.i} size={16} color={t.fg} style={{ marginTop: 2 }}/>
                    <div style={{ flex: 1, fontSize: 13.5, lineHeight: '19px', color: 'var(--fg-primary)' }}>
                      {it.l}
                    </div>
                  </div>
                );
              })}
            </div>
          </div>
        ))}

        <div style={{ marginTop: 12, padding: '14px 16px',
                      background: 'var(--color-bone-soft)', borderRadius: 4,
                      fontSize: 12.5, color: 'var(--fg-tertiary)',
                      fontStyle: 'italic', fontFamily: 'var(--font-display)' }}>
          Sensitive details are never shown. You see what Anna's network needs to see — nothing more.
        </div>
      </div>
    </PartnerShell>
  );
};

// ─────────────────────────────────────────────────────────────
// 2.4  Alert Detail (the "community noticing" moment)
// ─────────────────────────────────────────────────────────────
const P_Alert = () => (
  <PartnerShell active="alerts" alertOpen>
    <div style={{ padding: '20px 22px 40px' }}>
      <button style={{ background: 'none', border: 'none', color: 'var(--fg-secondary)',
              fontSize: 13, padding: 0, marginBottom: 18, cursor: 'pointer',
              display: 'inline-flex', alignItems: 'center', gap: 6 }}>
        <PI name="caret-left" size={14}/> All alerts
      </button>

      <PE tone="brass" style={{ marginBottom: 10 }}>A pattern from Anna · this week</PE>
      <h1 style={{ fontFamily: 'var(--font-display)', fontSize: 26, lineHeight: '32px',
                   fontWeight: 400, letterSpacing: '-0.012em', margin: '0 0 14px' }}>
        Worth a conversation, not an emergency.
      </h1>
      <p style={{ fontSize: 14.5, lineHeight: '22px', color: 'var(--fg-secondary)', margin: '0 0 22px' }}>
        Anna's rhythm has shifted since Tuesday. Sleep is later, two meetings have been missed, and her morning check-in tone dropped from <em style={{color:'var(--fg-primary)'}}>light</em> to <em style={{color:'var(--fg-primary)'}}>mixed</em> for three days running. Nothing has happened. She knows you are seeing this.
      </p>

      {/* Tiny chart */}
      <div style={{ background: 'var(--bg-surface)', border: '1px solid var(--border-hairline)',
                    borderRadius: 4, padding: '16px 18px', marginBottom: 20 }}>
        <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 10 }}>
          <PE>Sleep start · last 7 nights</PE>
          <span style={{ fontSize: 11, color: 'var(--fg-tertiary)' }}>10p — 2a</span>
        </div>
        <svg width="100%" height="56" viewBox="0 0 280 56" preserveAspectRatio="none">
          <line x1="0" y1="22" x2="280" y2="22" stroke="#D7CFBC" strokeDasharray="2 4"/>
          {[10, 18, 14, 22, 16, 44, 48].map((y, i) => (
            <rect key={i} x={i*40 + 18} y={y} width="6" height={56 - y - 2} rx="2"
                  fill={y > 38 ? '#A8843C' : '#1E3A2E'}/>
          ))}
        </svg>
        <div style={{ display: 'flex', justifyContent: 'space-around', marginTop: 4,
                       fontSize: 10.5, color: 'var(--fg-tertiary)' }}>
          {['Thu','Fri','Sat','Sun','Mon','Tue','Wed'].map((d,i) =>
            <span key={i} style={{ color: i >= 5 ? 'var(--color-brass-dark)' : undefined,
                                   fontWeight: i >= 5 ? 600 : 400 }}>{d}</span>)}
        </div>
      </div>

      <PE style={{ marginBottom: 10 }}>Recommended next step · written by Dr. Singh</PE>
      <div style={{ background: 'var(--color-ivy)', color: 'var(--color-bone)',
                    borderRadius: 4, padding: '18px 20px', marginBottom: 22 }}>
        <div style={{ fontFamily: 'var(--font-display)', fontStyle: 'italic',
                      fontSize: 15, lineHeight: '23px', marginBottom: 12 }}>
          "Call Anna tonight. Don't ask about the missed meetings — ask about her week. Mention nothing from this app. She knows."
        </div>
        <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
          <PB variant="brass" size="sm" icon="phone">Call Anna</PB>
          <PB variant="ghost" size="sm" style={{ background: 'rgba(242,237,226,0.08)',
                                                  color: 'var(--color-bone)',
                                                  borderColor: 'rgba(242,237,226,0.2)' }} icon="chat-circle">Text Anna</PB>
        </div>
      </div>

      <div style={{ background: 'var(--bg-surface)', border: '1px solid var(--border-hairline)',
                    borderRadius: 4, padding: '14px 16px', marginBottom: 12,
                    display: 'flex', alignItems: 'center', gap: 14 }}>
        <PI name="users-three" size={18} color="var(--color-ivy)"/>
        <div style={{ flex: 1, fontSize: 13, lineHeight: '18px' }}>
          Beth (sponsor) has also been notified. Dr. Singh's team is monitoring.
        </div>
      </div>

      <div style={{ display: 'flex', flexDirection: 'column', gap: 10, marginTop: 14 }}>
        <PB variant="secondary" full>Mark as handled with a note</PB>
        <PB variant="quiet" full>Escalate to Pine Tree's team</PB>
      </div>
    </div>
  </PartnerShell>
);

// ─────────────────────────────────────────────────────────────
// 2.5  Alert History
// ─────────────────────────────────────────────────────────────
const P_AlertHistory = () => {
  const alerts = [
    { d: 'May 14', l: 'Rhythm shift — sleep later, meetings missed', status: 'open',     by: 'Open · you and Beth notified' },
    { d: 'Apr 29', l: 'Two consecutive late nights',                  status: 'resolved', by: 'You called Anna · resolved' },
    { d: 'Apr 19', l: 'Single missed meeting',                        status: 'resolved', by: 'Auto-cleared · next meeting attended' },
    { d: 'Apr 11', l: 'Check-in tone dropped two days',                status: 'resolved', by: 'Beth visited · resolved' },
    { d: 'Apr 04', l: 'Welcome alert · class graduation',              status: 'info',     by: 'For your records' },
  ];
  const tones = {
    open:     { tone: 'ember',  label: 'Open' },
    resolved: { tone: 'moss',   label: 'Resolved' },
    info:     { tone: 'oat',    label: 'Info' },
  };
  return (
    <PartnerShell active="alerts">
      <div style={{ padding: '22px 22px 40px' }}>
        <PE style={{ marginBottom: 6 }}>Alert history · Anna</PE>
        <h1 style={{ fontFamily: 'var(--font-display)', fontSize: 24, fontWeight: 400,
                     letterSpacing: '-0.012em', margin: '0 0 18px' }}>
          Five notes in six weeks.
        </h1>
        {alerts.map((a, i) => {
          const t = tones[a.status];
          return (
            <div key={i} style={{
              display: 'flex', gap: 14, padding: '16px 0',
              borderTop: i === 0 ? '1px solid var(--border-hairline)' : 'none',
              borderBottom: '1px solid var(--border-hairline)',
            }}>
              <div style={{ width: 60, fontSize: 11.5, color: 'var(--fg-tertiary)',
                            letterSpacing: '0.04em', textTransform: 'uppercase', flexShrink: 0,
                            paddingTop: 2 }}>{a.d}</div>
              <div style={{ flex: 1, minWidth: 0 }}>
                <div style={{ fontSize: 14, fontWeight: 500, color: 'var(--fg-primary)', marginBottom: 4 }}>{a.l}</div>
                <div style={{ fontSize: 12, color: 'var(--fg-tertiary)' }}>{a.by}</div>
              </div>
              <PP tone={t.tone} dot>{t.label}</PP>
            </div>
          );
        })}
        <div style={{ marginTop: 22, padding: '14px 16px',
                      background: 'var(--color-bone-soft)', borderRadius: 4,
                      fontSize: 12.5, color: 'var(--fg-tertiary)',
                      fontStyle: 'italic', fontFamily: 'var(--font-display)' }}>
          A typical month for a steady member is one to three notes. This is on rhythm.
        </div>
      </div>
    </PartnerShell>
  );
};

// ─────────────────────────────────────────────────────────────
// 2.6  Send Encouragement / Message
// ─────────────────────────────────────────────────────────────
const P_Message = () => {
  const suggestions = [
    "Thinking of you tonight.",
    "Proud of how steady you've been.",
    "If you need a ride to St. Margaret's, say the word.",
    "Mama loves you.",
  ];
  const thread = [
    { who: 'them', t: '11:42 am', text: "Thinking of you tonight. Coming home Friday — your dad picked up tomatoes for the sauce." },
    { who: 'anna', t: '12:08 pm', text: "Love you. I'm at IOP at six. Will call after." },
    { who: 'them', t: '12:09 pm', text: "Take your time." },
  ];
  return (
    <PartnerShell active="message">
      <div style={{ padding: '22px 22px 40px' }}>
        <PE style={{ marginBottom: 6 }}>To Anna</PE>
        <h1 style={{ fontFamily: 'var(--font-display)', fontSize: 22, fontWeight: 400,
                     letterSpacing: '-0.008em', margin: '0 0 14px' }}>
          A short note goes a long way.
        </h1>

        {/* Thread */}
        <div style={{ background: 'var(--bg-surface)', border: '1px solid var(--border-hairline)',
                      borderRadius: 4, padding: '16px', marginBottom: 18 }}>
          {thread.map((m, i) => (
            <div key={i} style={{
              display: 'flex', justifyContent: m.who === 'them' ? 'flex-end' : 'flex-start',
              marginBottom: i < thread.length - 1 ? 10 : 0,
            }}>
              <div style={{
                maxWidth: '78%',
                background: m.who === 'them' ? 'var(--color-ivy)' : 'var(--color-bone)',
                color: m.who === 'them' ? 'var(--color-bone)' : 'var(--fg-primary)',
                padding: '10px 14px', borderRadius: 14,
                borderBottomRightRadius: m.who === 'them' ? 4 : 14,
                borderBottomLeftRadius: m.who === 'anna' ? 4 : 14,
                fontSize: 13.5, lineHeight: '19px',
              }}>
                {m.text}
                <div style={{ fontSize: 10, marginTop: 4,
                              color: m.who === 'them' ? 'rgba(242,237,226,0.55)' : 'var(--fg-tertiary)' }}>
                  {m.t}
                </div>
              </div>
            </div>
          ))}
        </div>

        <PE style={{ marginBottom: 10 }}>Try one of these</PE>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 8, marginBottom: 18 }}>
          {suggestions.map((s, i) => (
            <div key={i} style={{
              padding: '10px 14px', background: 'var(--bg-page)',
              border: '1px solid var(--border-hairline)', borderRadius: 4,
              fontSize: 13.5, lineHeight: '20px', color: 'var(--fg-secondary)',
              display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 12,
            }}>
              <span style={{ fontFamily: 'var(--font-display)', fontStyle: 'italic',
                             color: 'var(--fg-primary)' }}>"{s}"</span>
              <PI name="plus" size={14} color="var(--color-stone)"/>
            </div>
          ))}
        </div>

        <div style={{ display: 'flex', gap: 8, padding: '10px 14px',
                      border: '1px solid var(--color-ivy)', borderRadius: 4,
                      background: 'var(--bg-surface)' }}>
          <PI name="chat-circle" size={18} color="var(--color-ivy)" style={{ marginTop: 4 }}/>
          <div style={{ flex: 1, minHeight: 24, fontSize: 14, color: 'var(--fg-primary)' }}>
            Thinking of you tonight.<span style={{ color: 'var(--color-ivy)' }}>|</span>
          </div>
        </div>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginTop: 12 }}>
          <button style={{ background: 'none', border: 'none', fontSize: 12,
                  color: 'var(--fg-tertiary)', display: 'inline-flex', alignItems: 'center', gap: 6 }}>
            <PI name="clock" size={14}/> Schedule for evening
          </button>
          <PB variant="primary" size="sm">Send</PB>
        </div>
      </div>
    </PartnerShell>
  );
};

// ─────────────────────────────────────────────────────────────
// 2.7  Resources for Partners
// ─────────────────────────────────────────────────────────────
const P_Resources = () => {
  const articles = [
    { tag: 'Conversations', title: 'What to say when a meeting was missed.',
      mins: '4 min read', src: 'Hazelden Betty Ford library' },
    { tag: 'For mothers',   title: 'Holding the line without holding the leash.',
      mins: '6 min read', src: 'Pine Tree alumni writing' },
    { tag: 'Warning signs', title: 'The early shifts: sleep, isolation, and tone.',
      mins: '5 min read', src: 'NIDA digest' },
    { tag: 'When to call',  title: "If the rhythm doesn't return in a week.",
      mins: '3 min read', src: 'Pine Tree clinical' },
    { tag: 'Self-care',     title: 'You can love them and still rest.',
      mins: '7 min read', src: 'Al-Anon perspectives' },
  ];
  return (
    <PartnerShell active="learn">
      <div style={{ padding: '22px 22px 40px' }}>
        <PE style={{ marginBottom: 6 }}>For partners</PE>
        <h1 style={{ fontFamily: 'var(--font-display)', fontSize: 24, fontWeight: 400,
                     letterSpacing: '-0.012em', margin: '0 0 8px' }}>
          Reading for the long road.
        </h1>
        <p style={{ fontSize: 13.5, color: 'var(--fg-secondary)', margin: '0 0 22px' }}>
          Short pieces written for family, sponsors, and partners. Curated by Pine Tree's alumni team.
        </p>
        {articles.map((a, i) => (
          <div key={i} style={{
            padding: '16px 0', borderTop: '1px solid var(--border-hairline)',
            borderBottom: i === articles.length - 1 ? '1px solid var(--border-hairline)' : 'none',
            display: 'flex', alignItems: 'flex-start', gap: 14,
          }}>
            <div style={{
              width: 56, height: 72, flexShrink: 0,
              background: i % 3 === 0 ? 'var(--color-ivy)' : i % 3 === 1 ? 'var(--color-brass-soft)' : 'var(--color-moss-soft)',
              borderRadius: 2,
              display: 'flex', alignItems: 'center', justifyContent: 'center',
              fontFamily: 'var(--font-display)', fontSize: 22, fontWeight: 500,
              color: i % 3 === 0 ? 'var(--color-bone)' : 'var(--color-ivy-dark)',
            }}>A</div>
            <div style={{ flex: 1, minWidth: 0 }}>
              <div style={{ fontSize: 11, color: 'var(--color-brass-dark)',
                            letterSpacing: '0.06em', textTransform: 'uppercase',
                            fontWeight: 600, marginBottom: 4 }}>{a.tag}</div>
              <div style={{ fontFamily: 'var(--font-display)', fontSize: 16, lineHeight: '22px',
                            fontWeight: 500, color: 'var(--fg-primary)', marginBottom: 6 }}>
                {a.title}
              </div>
              <div style={{ fontSize: 11.5, color: 'var(--fg-tertiary)' }}>
                {a.mins} · {a.src}
              </div>
            </div>
          </div>
        ))}
      </div>
    </PartnerShell>
  );
};

// ─────────────────────────────────────────────────────────────
// 2.8  Partner Profile and Settings
// ─────────────────────────────────────────────────────────────
const P_PartnerProfile = () => {
  const rows = [
    { i: 'bell', l: 'Push notifications',  v: 'On · alerts and milestones' },
    { i: 'envelope', l: 'Email digests',   v: 'Sundays' },
    { i: 'chat-circle', l: 'SMS',          v: 'Only for serious alerts' },
    { i: 'moon', l: 'Quiet hours',         v: '10 pm – 7 am' },
    { i: 'users-three', l: 'Members paired with you', v: 'Anna Reyes' },
    { i: 'shield-check', l: 'Partner compact', v: 'Signed Apr 5' },
    { i: 'sign-out', l: 'Sign out',        v: null, danger: true },
  ];
  return (
    <PartnerShell active="profile">
      <div style={{ padding: '22px 22px 40px' }}>
        <div style={{
          display: 'flex', alignItems: 'center', gap: 16, marginBottom: 24,
          padding: '20px 22px', background: 'var(--bg-surface)',
          border: '1px solid var(--border-hairline)', borderRadius: 4,
        }}>
          <PA initials="MR" tone="ivy" size={52}/>
          <div style={{ flex: 1, minWidth: 0 }}>
            <div style={{ fontFamily: 'var(--font-display)', fontSize: 20, fontWeight: 500 }}>Maria Reyes</div>
            <div style={{ fontSize: 12, color: 'var(--fg-tertiary)' }}>Mother · in Anna's network since Apr 5</div>
          </div>
        </div>

        <PE style={{ marginBottom: 10 }}>Settings</PE>
        <div style={{ background: 'var(--bg-surface)', border: '1px solid var(--border-hairline)',
                      borderRadius: 4, overflow: 'hidden' }}>
          {rows.map((r, i) => (
            <div key={i} style={{
              display: 'flex', alignItems: 'center', gap: 14,
              padding: '14px 18px',
              borderBottom: i < rows.length - 1 ? '1px solid var(--border-hairline)' : 'none',
            }}>
              <PI name={r.i} size={20} color={r.danger ? 'var(--color-ember)' : 'var(--color-ivy)'}/>
              <div style={{ flex: 1, minWidth: 0 }}>
                <div style={{ fontSize: 14.5, fontWeight: 500,
                              color: r.danger ? 'var(--color-ember)' : 'var(--fg-primary)' }}>{r.l}</div>
                {r.v && <div style={{ fontSize: 12, color: 'var(--fg-tertiary)' }}>{r.v}</div>}
              </div>
              {!r.danger && <PI name="caret-right" size={14} color="var(--color-stone-soft)"/>}
            </div>
          ))}
        </div>

        <div style={{ marginTop: 24, fontSize: 11, color: 'var(--fg-tertiary)',
                      textAlign: 'center', letterSpacing: '0.04em',
                      fontFamily: 'var(--font-display)', fontStyle: 'italic' }}>
          A membership of Pine Tree Recovery
        </div>
      </div>
    </PartnerShell>
  );
};

window.Partner = { P_Onboard, P_Overview, P_Timeline, P_Alert, P_AlertHistory, P_Message, P_Resources, P_PartnerProfile };
