// screens-tabs.jsx — 지도 / 앨범 / 지갑 / 집 tabs. Persona-aware.

// ── 지도 (부산 지도 · 가고 싶은 곳 · 맞춤 추천) ──────────────────
function MapTab({ persona, openSheet }) {
  const [sel, setSel] = React.useState(null);
  const [wished, setWished] = React.useState({});
  // pin positions on the stylized canvas (x%, y%)
  const POS = { p1: [22, 64], p2: [44, 40], p3: [68, 30], p4: [34, 78], p5: [80, 60], p6: [56, 70] };
  const isHost = persona === 'host';
  const selPin = JJ.pins.find(p => p.id === sel);

  return (
    <div>
      <ScreenTitle
        kicker={isHost ? '나만의 부산 지도 · 큐레이션' : '나만의 부산 지도'}
        title={isHost ? "'우리의 부산'을 그려요" : '쩨가 고른 우리의 부산'}
        sub={isHost ? '핀이 곧 추천이 돼요. 트립을 넘어 집에 쌓입니다.' : '관광지 top 10이 아니라, 우리가 진짜 가는 곳.'}
        kickerColor="var(--sea)"
      />
      {/* stylized map canvas */}
      <div style={{ position: 'relative', height: 240, borderRadius: 18, overflow: 'hidden', border: '1px solid var(--line-soft)', background: 'linear-gradient(155deg,#A9CBD6 0%,#BcD9DE 30%,#EBDEC0 52%,#E6D2A8 100%)' }}>
        {/* sea label + coastline */}
        <svg viewBox="0 0 300 240" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%' }} preserveAspectRatio="none">
          <path d="M0,120 Q60,100 110,135 T210,150 T300,130 L300,240 L0,240 Z" fill="rgba(233,210,168,.65)" />
          <path d="M0,120 Q60,100 110,135 T210,150 T300,130" fill="none" stroke="rgba(255,255,255,.5)" strokeWidth="2" />
        </svg>
        <div style={{ position: 'absolute', left: 14, top: 12, fontFamily: 'var(--f-hand)', fontSize: 'calc(20px * var(--hand-scale))', color: 'rgba(32,89,107,.6)' }}>부산 앞바다</div>
        {JJ.pins.map((p) => {
          const [x, y] = POS[p.id] || [50, 50];
          const on = sel === p.id;
          return (
            <button key={p.id} onClick={() => setSel(on ? null : p.id)} style={{
              position: 'absolute', left: `${x}%`, top: `${y}%`, transform: 'translate(-50%,-100%)',
              background: 'none', border: 'none', cursor: 'pointer', padding: 0, zIndex: on ? 5 : 2,
            }}>
              <div style={{
                width: on ? 30 : 24, height: on ? 30 : 24, borderRadius: '50% 50% 50% 0', transform: 'rotate(-45deg)',
                background: wished[p.id] ? 'var(--coral)' : 'var(--sea)', boxShadow: '0 3px 8px rgba(0,0,0,.28)',
                display: 'flex', alignItems: 'center', justifyContent: 'center', transition: '.15s',
                border: '2px solid #fff',
              }}>
                <div style={{ transform: 'rotate(45deg)' }}><JJIcon name={wished[p.id] ? 'heart' : 'pin'} size={on ? 13 : 11} color="#fff" sw={2.4} fill={wished[p.id]} /></div>
              </div>
            </button>
          );
        })}
      </div>

      {/* selected pin detail */}
      {selPin && (
        <Card pad={0} style={{ marginTop: 12, overflow: 'hidden' }}>
          <div style={{ display: 'flex', gap: 12, padding: 12 }}>
            <Photo scene={selPin.scene} h={70} r={12} style={{ width: 84, flexShrink: 0 }} />
            <div style={{ flex: 1, minWidth: 0 }}>
              <div style={{ display: 'flex', alignItems: 'center', gap: 7 }}>
                <span style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 16, color: 'var(--ink)' }}>{selPin.name}</span>
                <Tag tone="amber">{selPin.tag}</Tag>
              </div>
              <div style={{ fontFamily: 'var(--f-hand)', fontSize: 'calc(17px * var(--hand-scale))', color: 'var(--ink-2)', marginTop: 4 }}>“{selPin.note}”</div>
            </div>
          </div>
          <div style={{ padding: '0 12px 12px' }}>
            {isHost
              ? <BtnGhost icon="edit" full>핀 편집하기</BtnGhost>
              : <BtnPrimary icon={wished[selPin.id] ? 'check' : 'heart'} full onClick={() => setWished(w => ({ ...w, [selPin.id]: !w[selPin.id] }))} tone={wished[selPin.id] ? 'sea' : 'coral'}>
                  {wished[selPin.id] ? '가고 싶은 곳에 담겼어요' : '가고 싶은 곳에 담기'}
                </BtnPrimary>}
          </div>
        </Card>
      )}

      {/* 가고 싶은 곳 (위시리스트) */}
      <div style={{ marginTop: 18, display: 'flex', alignItems: 'center', gap: 8 }}>
        <JJIcon name="heart" size={17} color="var(--coral)" fill />
        <span style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 16, color: 'var(--ink)', flex: 1 }}>{isHost ? '민서가 가고 싶은 곳' : '가고 싶은 곳'}</span>
        <Tag tone="coral">{JJ.wishlist.length}곳 · 늘 우선</Tag>
      </div>
      <div style={{ marginTop: 10, display: 'flex', flexDirection: 'column', gap: 8 }}>
        {JJ.wishlist.map(w => (
          <Card key={w.id} pad={11} style={{ display: 'flex', alignItems: 'center', gap: 11 }}>
            <Photo scene={w.scene || (JJ.pins.find(p => p.id === w.pinId) || {}).scene || 'sea'} h={42} r={10} style={{ width: 42, flexShrink: 0 }} />
            <div style={{ flex: 1 }}>
              <div style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 14, color: 'var(--ink)' }}>{w.name}</div>
              <div style={{ fontFamily: 'var(--f-body)', fontSize: 11.5, color: 'var(--ink-3)' }}>{w.when}</div>
            </div>
            <Tag tone={w.by === 'host' ? 'sea' : 'coral'}>{w.by === 'host' ? '쩨 추천' : '민서'}</Tag>
          </Card>
        ))}
      </div>

      {/* 맞춤 추천 — 요청 시에만 (기능 08) */}
      {!isHost && (
        <Card pad={15} style={{ marginTop: 14, background: 'var(--accent-soft)', border: '1px solid color-mix(in srgb, var(--amber) 30%, transparent)' }}>
          <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
            <JJIcon name="spark" size={20} color="var(--amber)" />
            <div style={{ flex: 1 }}>
              <div style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 14.5, color: 'var(--ink)' }}>가고 싶은 데가 없을 땐</div>
              <div style={{ fontFamily: 'var(--f-body)', fontSize: 12, color: 'var(--ink-2)' }}>“추천해줘” 하면 쩨 지도에서 골라줄게요</div>
            </div>
            <BtnPrimary tone="amber" onClick={() => openSheet('recommend')}>추천</BtnPrimary>
          </div>
        </Card>
      )}
      {isHost && (
        <BtnPrimary icon="plus" full tone="sea" style={{ marginTop: 14 }}>새 장소 핀 등록</BtnPrimary>
      )}
    </div>
  );
}

// ── 앨범 (공유 앨범) ─────────────────────────────────────────
function AlbumTab({ persona, scr }) {
  if (scr === 'empty') {
    return (
      <div>
        <ScreenTitle kicker="공유 앨범" title="함께 찍은 사흘" sub="각자 폰에 흩어지는 대신, 한곳에 모여 추억 선물의 재료가 돼요." kickerColor="var(--sea)" />
        <Card pad={20} style={{ textAlign: 'center', background: 'var(--paper-2)', borderStyle: 'dashed' }}>
          <div style={{ width: 50, height: 50, borderRadius: 15, margin: '0 auto 11px', background: 'color-mix(in srgb, var(--sea) 12%, var(--card))', display: 'flex', alignItems: 'center', justifyContent: 'center' }}><JJIcon name="album" size={24} color="var(--sea)" /></div>
          <div style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 16, color: 'var(--ink)' }}>아직 사진이 없어요</div>
          <div style={{ fontFamily: 'var(--f-body)', fontSize: 12.5, color: 'var(--ink-3)', margin: '5px 0 14px', lineHeight: 1.5 }}>함께 다니며 첫 사진을 올려봐요. 찍은 곳은 지도에 핀으로 남아요.</div>
          <BtnPrimary icon="album" full tone="sea">첫 사진 올리기</BtnPrimary>
        </Card>
      </div>
    );
  }
  return (
    <div>
      <ScreenTitle kicker="공유 앨범" title="함께 찍은 사흘" sub="각자 폰에 흩어지는 대신, 한곳에 모여 추억 선물의 재료가 돼요." kickerColor="var(--sea)" />
      <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 9 }}>
        {JJ.album.map((a, i) => (
          <div key={a.id} style={{ gridColumn: i === 0 ? '1 / -1' : 'auto' }}>
            <Photo scene={a.scene} h={i === 0 ? 150 : 110} r={14} label={a.cap}>
              <div style={{ position: 'absolute', top: 7, right: 7, background: 'rgba(0,0,0,.32)', borderRadius: 999, padding: '2px 7px', display: 'flex', alignItems: 'center', gap: 3 }}>
                <JJIcon name="pin" size={10} color="#fff" sw={2} />
                <span style={{ fontFamily: 'var(--f-body)', fontSize: 9.5, color: '#fff' }}>{a.pin}</span>
              </div>
            </Photo>
          </div>
        ))}
      </div>
      <Card pad={13} style={{ marginTop: 12, display: 'flex', alignItems: 'center', gap: 10, background: 'var(--paper-2)' }}>
        <JJIcon name="map" size={18} color="var(--sea)" />
        <div style={{ flex: 1, fontFamily: 'var(--f-body)', fontSize: 12.5, color: 'var(--ink-2)' }}>찍은 곳이 부산 지도에 <b style={{ color: 'var(--ink)' }}>핀으로 남아요</b>.</div>
      </Card>
      <BtnPrimary icon="album" full tone="sea" style={{ marginTop: 12 }}>사진 올리기</BtnPrimary>
    </div>
  );
}

// ── 지갑 (공동지갑) ──────────────────────────────────────────
function WalletTab({ persona, tripState, scr }) {
  const w = JJ.wallet;
  const settling = scr === 'settled';
  const empty = scr === 'empty';
  const balance = empty ? 0 : w.balance;
  const tx = empty ? [] : w.tx;
  return (
    <div>
      <ScreenTitle kicker="공동지갑" title="공평하게, 조용히" sub="청구가 아니라 공평함까지만. 숙박은 무료예요." kickerColor="var(--amber)" />
      {/* balance */}
      <Card pad={0} style={{ overflow: 'hidden' }}>
        <div style={{ padding: 18, background: 'linear-gradient(150deg, var(--sea), color-mix(in srgb, var(--sea) 70%, #000 12%))', color: '#fff' }}>
          <div style={{ fontFamily: 'var(--f-body)', fontSize: 12, opacity: .85 }}>{settling ? '정산 후 남은 잔액' : '이번 트립 공동지갑 잔액'}</div>
          <div style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 34, marginTop: 2 }}>{balance.toLocaleString()}<span style={{ fontSize: 18, marginLeft: 3 }}>원</span></div>
          <div style={{ display: 'flex', gap: 16, marginTop: 12 }}>
            {w.members.map(m => (
              <div key={m.who} style={{ display: 'flex', alignItems: 'center', gap: 7 }}>
                <Avatar name={m.name[0]} tone={m.who} size={26} />
                <div>
                  <div style={{ fontFamily: 'var(--f-body)', fontSize: 11, opacity: .8 }}>{m.name} 충전</div>
                  <div style={{ fontFamily: 'var(--f-body)', fontSize: 13, fontWeight: 600 }}>{empty ? '0' : m.put.toLocaleString()}원</div>
                </div>
              </div>
            ))}
          </div>
        </div>
        <div style={{ padding: 12, display: 'flex', gap: 8 }}>
          <BtnGhost icon="plus" full>충전</BtnGhost>
          <BtnGhost icon="wallet" full>지출 기록</BtnGhost>
        </div>
      </Card>

      {empty ? (
        <Card pad={18} style={{ marginTop: 12, textAlign: 'center', background: 'var(--paper-2)', borderStyle: 'dashed' }}>
          <div style={{ fontFamily: 'var(--f-hand)', fontSize: 'calc(18px * var(--hand-scale))', color: 'var(--ink-3)' }}>아직 모으기 전이에요</div>
          <div style={{ fontFamily: 'var(--f-body)', fontSize: 12.5, color: 'var(--ink-3)', marginTop: 4 }}>다 같이 조금씩 넣으면, 공동비용이 여기서 빠져요.</div>
        </Card>
      ) : (
      <React.Fragment>
      {/* tx list */}
      <div style={{ marginTop: 14, marginBottom: 8, fontFamily: 'var(--f-body)', fontSize: 11.5, fontWeight: 600, letterSpacing: '.04em', color: 'var(--ink-3)' }}>내역 · 모두에게 동일하게 보여요</div>
      <Card pad={0}>
        {tx.map((t, i) => (
          <div key={t.id} style={{ display: 'flex', alignItems: 'center', gap: 11, padding: '12px 15px', borderTop: i ? '1px solid var(--line-soft)' : 'none' }}>
            <div style={{ width: 30, height: 30, borderRadius: 9, flexShrink: 0, display: 'flex', alignItems: 'center', justifyContent: 'center', background: t.amt > 0 ? 'color-mix(in srgb, var(--sea) 12%, var(--card))' : 'var(--accent-soft)' }}>
              <JJIcon name={t.amt > 0 ? 'plus' : 'wallet'} size={15} color={t.amt > 0 ? 'var(--sea)' : 'var(--coral)'} />
            </div>
            <div style={{ flex: 1 }}>
              <div style={{ fontFamily: 'var(--f-body)', fontSize: 13.5, color: 'var(--ink)' }}>{t.text}</div>
              <div style={{ fontFamily: 'var(--f-body)', fontSize: 11, color: 'var(--ink-3)' }}>{t.who === 'host' ? '지혜' : '민서'} · {t.t}</div>
            </div>
            <div style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 14, color: t.amt > 0 ? 'var(--sea)' : 'var(--ink)' }}>{t.amt > 0 ? '+' : ''}{t.amt.toLocaleString()}</div>
          </div>
        ))}
      </Card>
      </React.Fragment>
      )}
      {settling && (
        <Card pad={15} style={{ marginTop: 12, background: 'var(--accent-soft)', border: '1px solid color-mix(in srgb, var(--amber) 30%, transparent)', textAlign: 'center' }}>
          <div style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 15, color: 'var(--ink)' }}>떠나는 날, 한 번에 정산</div>
          <div style={{ fontFamily: 'var(--f-body)', fontSize: 12.5, color: 'var(--ink-2)', margin: '4px 0 12px' }}>남은 {w.balance.toLocaleString()}원을 공평하게 나눠 돌려줘요.</div>
          <BtnPrimary icon="check" full tone="amber">정산하고 마무리</BtnPrimary>
        </Card>
      )}
    </div>
  );
}

// ── 집 (Home — 집에 귀속된 것들) ──────────────────────────────
function HomeTab({ persona, sub, setSub, scr, openSheet }) {
  const isHost = persona === 'host';
  // detail views
  if (sub === 'kit') return <KitView />;
  if (sub === 'guide') return <GuideView />;
  if (sub === 'prefs') return <PrefsView isHost={isHost} scr={scr} />;
  if (sub === 'guestbook') return <GuestbookView isHost={isHost} scr={scr} />;
  if (sub === 'journeys') return <CollectionView persona={persona} openSheet={openSheet} />;

  // menu
  return (
    <div>
      <ScreenTitle kicker="집 · Home" title={JJ.home.name} sub={`${JJ.home.sub} — 트립을 넘어 쌓이는 것들.`} kickerColor="var(--coral)" />
      <Card pad={16} style={{ background: 'var(--paper-2)', display: 'flex', alignItems: 'center', gap: 12 }}>
        <Avatar name={JJ.host.initial} tone="host" size={46} ring />
        <div style={{ flex: 1 }}>
          <div style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 16, color: 'var(--ink)' }}>{JJ.host.name}의 집 · {JJ.home.place}</div>
          <div style={{ fontFamily: 'var(--f-body)', fontSize: 12, color: 'var(--ink-3)' }}>거쳐간 손님 {JJ.home.visitsCount}명 · 방명록 {JJ.guestbook.length}줄</div>
        </div>
      </Card>
      <div style={{ marginTop: 12, display: 'flex', flexDirection: 'column', gap: 9 }}>
        <EntryCard icon="key" title="웰컴 키트" desc="도어락 · 와이파이 · 충전기 · 생필품" tone="amber" onClick={() => setSub('kit')} />
        <EntryCard icon="home" title="집 안내" desc="오는 법 · 도착 · 날씨 · 동선" tone="sea" onClick={() => setSub('guide')} />
        <EntryCard icon="user" title={isHost ? '손님 선호 (받은 것)' : '내 선호 남기기'} desc="알레르기 · 음식 취향 · 기상" tone="coral" onClick={() => setSub('prefs')} />
        <EntryCard icon="book" title="방명록" desc="이 집을 거쳐간 사람들의 한 줄" tone="sea" onClick={() => setSub('guestbook')} />
        <EntryCard icon="star" title={isHost ? '손님들의 여정' : '나의 여정'} desc="금액 · 루트 · 사진 · 추억 모아보기" tone="coral" onClick={() => setSub('journeys')} />
      </div>
      <div style={{ marginTop: 16, textAlign: 'center', fontFamily: 'var(--f-hand)', fontSize: 'calc(19px * var(--hand-scale))', color: 'var(--coral)' }}>쩨를 위해, 사랑으로.</div>
    </div>
  );
}

function SubHeader({ kicker, title, sub, color }) {
  return <ScreenTitle kicker={kicker} title={title} sub={sub} kickerColor={color} />;
}

function KitView() {
  return (
    <div>
      <SubHeader kicker="웰컴 키트 · 집에 귀속" title="묻지 않아도 괜찮아요" sub="도착하면 스스로 다 찾을 수 있게. 트립마다 재사용돼요." color="var(--amber)" />
      <div style={{ display: 'flex', flexDirection: 'column', gap: 9 }}>
        {JJ.kit.map(k => (
          <Card key={k.k} pad={14} style={{ display: 'flex', alignItems: 'center', gap: 13 }}>
            <div style={{ width: 42, height: 42, borderRadius: 12, flexShrink: 0, display: 'flex', alignItems: 'center', justifyContent: 'center', background: 'color-mix(in srgb, var(--amber) 13%, var(--card))' }}><JJIcon name={k.icon} size={20} color="var(--amber)" /></div>
            <div style={{ flex: 1 }}>
              <div style={{ fontFamily: 'var(--f-body)', fontSize: 11.5, color: 'var(--ink-3)' }}>{k.title}</div>
              <div style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 15.5, color: 'var(--ink)' }}>{k.v}</div>
            </div>
            <div style={{ fontFamily: 'var(--f-hand)', fontSize: 'calc(15px * var(--hand-scale))', color: 'var(--coral)', maxWidth: 92, textAlign: 'right', lineHeight: 1.1 }}>{k.hint}</div>
          </Card>
        ))}
      </div>
    </div>
  );
}

function GuideView() {
  const g = JJ.guide;
  return (
    <div>
      <SubHeader kicker="집 안내 · House Guide" title="헤매지 않게, 한 화면에" color="var(--sea)" />
      <Photo scene="hill" h={120} label="동래, 우리집 가는 길" />
      <Card pad={15} style={{ marginTop: 12 }}>
        <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 6 }}><JJIcon name="pin" size={16} color="var(--sea)" /><span style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 14.5, color: 'var(--ink)' }}>{g.address}</span></div>
        <div style={{ fontFamily: 'var(--f-body)', fontSize: 13, color: 'var(--ink-2)', lineHeight: 1.6 }}>{g.how}</div>
      </Card>
      <Card pad={15} style={{ marginTop: 10, display: 'flex', alignItems: 'center', gap: 13 }}>
        <div style={{ width: 48, height: 48, borderRadius: 12, background: 'linear-gradient(160deg,#9FC9D6,#E8C79B)', display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0 }}><JJIcon name="sun" size={24} color="#fff" /></div>
        <div style={{ flex: 1 }}>
          <div style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 18, color: 'var(--ink)' }}>{g.weather.t} · {g.weather.d}</div>
          <div style={{ fontFamily: 'var(--f-hand)', fontSize: 'calc(16px * var(--hand-scale))', color: 'var(--coral)' }}>{g.weather.tip}</div>
        </div>
      </Card>
    </div>
  );
}

function PrefsEmpty({ isHost }) {
  return (
    <div>
      <SubHeader kicker="손님 선호 · Preference" title={isHost ? '아직 받은 선호가 없어요' : '미리 알려줄게요'} sub={isHost ? '민서가 선호를 남기면 여기에 보여요.' : '딱 하나만 남겨도 환대가 달라져요.'} color="var(--coral)" />
      <Card pad={20} style={{ textAlign: 'center', background: 'var(--paper-2)', borderStyle: 'dashed' }}>
        <div style={{ width: 48, height: 48, borderRadius: 14, margin: '0 auto 10px', background: 'var(--accent-soft)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}><JJIcon name="user" size={23} color="var(--coral)" /></div>
        <div style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 15.5, color: 'var(--ink)' }}>{isHost ? '선호 입력 전' : '아직 안 남긴 상태'}</div>
        <div style={{ fontFamily: 'var(--f-body)', fontSize: 12.5, color: 'var(--ink-3)', margin: '5px 0 14px', lineHeight: 1.5 }}>{isHost ? '초대 링크에서 민서가 선호를 남기면 자동으로 채워져요.' : '알레르기·취향을 한번 남겨볼까요?'}</div>
        {!isHost && <BtnPrimary icon="plus" full>선호 처음 남기기</BtnPrimary>}
      </Card>
    </div>
  );
}

function PrefsView({ isHost, scr }) {
  if (scr === 'empty') return <PrefsEmpty isHost={isHost} />;
  return (
    <div>
      <SubHeader kicker="손님 선호 · Preference" title={isHost ? '민서를 배려할 메모' : '미리 알려줄게요'} sub={isHost ? '식사·환대에 반영해요.' : '알레르기·취향을 남기면 쩨가 알아서 배려해요.'} color="var(--coral)" />
      <div style={{ display: 'flex', flexDirection: 'column', gap: 9 }}>
        {JJ.prefs.map((p, i) => (
          <Card key={i} pad={14} style={{ display: 'flex', alignItems: 'center', gap: 12, borderLeft: p.warn ? '4px solid var(--coral)' : '1px solid var(--line-soft)' }}>
            <div style={{ flex: 1 }}>
              <div style={{ fontFamily: 'var(--f-body)', fontSize: 11.5, color: 'var(--ink-3)' }}>{p.k}</div>
              <div style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 15.5, color: p.warn ? 'var(--coral)' : 'var(--ink)' }}>{p.v}</div>
            </div>
            {p.warn && <Tag tone="coral" solid>주의</Tag>}
          </Card>
        ))}
      </div>
      {!isHost && <BtnPrimary icon="plus" full style={{ marginTop: 12 }}>선호 추가하기</BtnPrimary>}
    </div>
  );
}

function GuestbookView({ isHost, scr }) {
  const after = scr !== 'before';
  const list = JJ.guestbook.map(g => g.pending ? { ...g, pending: !after, text: after ? '막걸리도 흰여울 아침도 다 좋았어요. 여기 오면 부산이 우리집 같아져요. 또 올게요!' : g.text } : g);
  return (
    <div>
      <SubHeader kicker="방명록 · Guestbook" title="이 집을 거쳐간 사람들" sub="흩어질 고마움이 집의 역사가 돼요." color="var(--sea)" />
      <div style={{ display: 'flex', flexDirection: 'column', gap: 11 }}>
        {list.map(g => (
          <Card key={g.id} pad={15} style={{ background: g.pending ? 'var(--accent-soft)' : 'var(--card)', border: g.pending ? '1px dashed var(--coral)' : '1px solid var(--line-soft)' }}>
            <div style={{ display: 'flex', alignItems: 'center', gap: 9, marginBottom: 7 }}>
              <Avatar name={g.name[0]} tone={g.tone} size={28} />
              <span style={{ fontFamily: 'var(--f-display)', fontWeight: 700, fontSize: 14, color: 'var(--ink)' }}>{g.name}</span>
              <span style={{ fontFamily: 'var(--f-body)', fontSize: 11, color: 'var(--ink-3)', marginLeft: 'auto' }}>{g.date}</span>
            </div>
            <Hand size={21} color={g.pending ? 'var(--ink-3)' : 'var(--ink)'} style={{ display: 'block' }}>{g.text}</Hand>
          </Card>
        ))}
      </div>
      <BtnPrimary icon="edit" full tone="sea" style={{ marginTop: 12 }}>{isHost ? '손님에게 방명록 권하기' : '나도 한 줄 남기기'}</BtnPrimary>
    </div>
  );
}

Object.assign(window, { MapTab, AlbumTab, WalletTab, HomeTab });
