# #148 — Threaded Split-View Discussion Reader

> Topic-threaded team discussion workspace with unread stream badges, live reply composer, emoji reactions, and mobile drill-down.

## Metadata

- **Index**: #148
- **Slug**: `threaded-split-discussion`
- **Kind**: `ui`
- **Family**: Communication & Triage
- **Theme**: `light`
- **Mobile Strength**: `native-first`
- **Tags**: `threaded-chat`, `split-view`, `discussions`, `team-communication`, `reactions`, `topic-streams`
- **Best For**: Async engineering and open-source team chat, Community forums and Q&A workspaces, Customer support and incident rooms, Course and cohort discussion boards
- **Real-World Inspiration**: [Zulip](https://zulip.com/)
- **Detail Page**: https://templates.michaelpitts.net/t/threaded-split-discussion
- **Live Demo**: https://templates.michaelpitts.net/demos/threaded-split-discussion.html
- **JSON API**: https://templates.michaelpitts.net/api/templates/threaded-split-discussion

## Why This Aesthetic Is Unique

Organizes high-volume team chat into discrete named topics rather than chaotic chronological streams, letting readers resolve, bookmark, and reply in parallel while drilling down cleanly on phones.

## Color Palette

| Role | Name | Hex |
|------|------|-----|
| `canvas` | Sandstone Mist | `#F7F6F2` |
| `surface` | Thread White | `#FFFFFF` |
| `ink` | Deep Indigo Ink | `#1A1E2C` |
| `accent` | Zulip Indigo | `#4338CA` |
| `muted` | Stream Gray | `#646B7D` |

## Typography

- **Display**: `Inter`
- **Body**: `Inter`
- **Mono**: `JetBrains Mono`
- **Scale Notes**: 17px topic header, 14.5px/1.6 message prose, 12px stream tag pills, 11px mono unread counters.
- **Google Fonts**: https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600&display=swap
  ```html
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600&display=swap">
  ```

## Layout Architecture

320px topic/stream list on the left + fluid threaded conversation view with sticky reply composer on the right; single-pane drill-down with Back button below 820px.

## Interaction & Micro-Motion Rules

Filter by stream, click any topic to clear its unread badge, toggle emoji reactions, mark a topic Resolved or Bookmarked, and post live replies into the thread.

## Mobile & Responsive Rules

Promotes the topic feed and active thread into full-screen views on 390px with a clear '← Topics' header button and a thumb-friendly bottom reply bar.

## Agent Guardrails

### DO
- Always display the stream/channel badge alongside each topic title for instant context.
- Allow one-tap reaction toggling and explicit Resolved status toggling on threads.
- Use full-screen list-to-thread drill-down on viewports under 820px.

### DON'T
- Never bury the reply composer inside a secondary modal when reading a thread.
- Avoid mixing unrelated topics into a single unthreaded firehose.

## Complete Standalone Starter Code

File: `demos/threaded-split-discussion.html`

```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Strata Forum — Threaded Split-View Discussion</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
  :root {
    --bg: #F6F3EC;
    --surface: #FFFFFF;
    --sand: #EFEAE0;
    --indigo: #3730A3;
    --indigo-soft: #EEF2FF;
    --indigo-mid: #4F46E5;
    --ink: #1C1B22;
    --muted: #656372;
    --border: rgba(28, 27, 34, 0.11);
    --green: #0F766E;
    --green-soft: #CCFBF1;
    --amber: #B45309;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  html, body {
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
  }

  .shell {
    display: grid;
    grid-template-rows: 56px 1fr;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
  }

  .header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .brand-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--indigo);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.85rem;
  }

  .brand h1 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
  }

  .stream-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .stream-tabs::-webkit-scrollbar { display: none; }

  .stream-chip {
    min-height: 38px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--muted);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.14s ease;
  }

  .stream-chip.active {
    background: var(--indigo);
    color: #fff;
    border-color: var(--indigo);
  }

  /* Split Pane */
  .split {
    display: grid;
    grid-template-columns: 356px 1fr;
    min-height: 0;
    overflow: hidden;
  }

  /* Left Feed */
  .feed-pane {
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .feed-subhead {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--muted);
  }

  .feed-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .topic-item {
    width: 100%;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 13px;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.14s ease, background 0.14s ease;
  }

  .topic-item:hover { border-color: rgba(79, 70, 229, 0.35); }
  .topic-item.active {
    background: var(--indigo-soft);
    border-color: var(--indigo-mid);
  }

  .topic-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .stream-pill {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--indigo);
    background: rgba(79, 70, 229, 0.1);
    padding: 2px 7px;
    border-radius: 5px;
  }

  .topic-badges {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .unread-dot {
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--indigo-mid);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: grid;
    place-items: center;
  }

  .resolved-tag {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--green);
    background: var(--green-soft);
    padding: 2px 6px;
    border-radius: 4px;
  }

  .topic-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
  }

  .topic-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--muted);
  }

  /* Right Thread Pane */
  .thread-pane {
    background: var(--surface);
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .thread-head {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #FDFCFA;
  }

  .thread-head-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }

  .back-btn {
    display: none;
    min-width: 44px;
    min-height: 44px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    place-items: center;
    cursor: pointer;
  }

  .thread-title-wrap {
    min-width: 0;
  }

  .thread-title-wrap h2 {
    font-size: 1.02rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .thread-title-wrap p {
    font-size: 0.76rem;
    color: var(--muted);
  }

  .thread-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  .action-btn {
    min-height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.14s ease;
  }

  .action-btn:hover { background: var(--bg); }
  .action-btn.resolved {
    background: var(--green-soft);
    border-color: var(--green);
    color: var(--green);
  }
  .action-btn.bookmarked {
    background: #FEF3C7;
    border-color: var(--amber);
    color: var(--amber);
  }

  .messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .msg {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 12px;
    align-items: start;
  }

  .avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: #fff;
  }

  .msg-body {
    min-width: 0;
  }

  .msg-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
  }

  .msg-author { font-weight: 600; font-size: 0.88rem; }
  .msg-role { font-size: 0.72rem; color: var(--muted); }
  .msg-time { font-size: 0.72rem; color: var(--muted); margin-left: auto; }

  .msg-text {
    font-size: 0.9rem;
    line-height: 1.56;
    color: #292732;
    margin-bottom: 8px;
    white-space: pre-wrap;
  }

  .reactions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }

  .react-btn {
    min-height: 32px;
    padding: 0 9px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    font-family: inherit;
    font-size: 0.78rem;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.12s ease;
  }

  .react-btn:hover { border-color: var(--indigo-mid); }
  .react-btn.reacted {
    background: var(--indigo-soft);
    border-color: var(--indigo-mid);
    color: var(--indigo);
    font-weight: 600;
  }

  /* Composer */
  .composer {
    border-top: 1px solid var(--border);
    padding: 12px 20px 14px;
    background: #FDFCFA;
    display: flex;
    gap: 10px;
    align-items: flex-end;
  }

  .composer textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 0.88rem;
    background: var(--surface);
    color: var(--ink);
    outline: none;
  }

  .composer textarea:focus {
    border-color: var(--indigo-mid);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.14);
  }

  .send-btn {
    min-height: 44px;
    padding: 0 18px;
    border-radius: 10px;
    border: none;
    background: var(--indigo);
    color: #fff;
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
  }

  .send-btn:hover { background: var(--indigo-mid); }

  @media (max-width: 820px) {
    .header { padding: 0 12px; }
    .brand h1 { font-size: 0.92rem; }
    .split { grid-template-columns: 1fr; }
    .split.mobile-thread .feed-pane { display: none; }
    .split:not(.mobile-thread) .thread-pane { display: none; }
    .back-btn { display: grid; }
    .thread-head { padding: 10px 12px; }
    .action-btn span { display: none; }
    .action-btn { min-width: 44px; min-height: 44px; justify-content: center; padding: 0; }
    .messages { padding: 14px 14px; }
    .composer { padding: 10px 12px; }
  }
</style>
</head>
<body>
<div class="shell">
  <header class="header">
    <div class="brand">
      <div class="brand-icon">S</div>
      <h1>Strata Discussions</h1>
    </div>
    <nav class="stream-tabs" id="streamTabs" aria-label="Filter by stream"></nav>
  </header>

  <div class="split" id="splitView">
    <aside class="feed-pane" aria-label="Topic feed">
      <div class="feed-subhead">
        <span id="feedSummary">5 active topics</span>
        <span id="unreadTotal">4 unread</span>
      </div>
      <div class="feed-list" id="feedList"></div>
    </aside>

    <main class="thread-pane" aria-label="Selected discussion thread">
      <div class="thread-head">
        <div class="thread-head-left">
          <button class="back-btn" id="backBtn" type="button" aria-label="Back to topics">
            <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 18l-6-6 6-6"/></svg>
          </button>
          <div class="thread-title-wrap">
            <h2 id="threadTitle">Topic</h2>
            <p id="threadSub">#stream &middot; 3 replies</p>
          </div>
        </div>
        <div class="thread-actions">
          <button class="action-btn" id="bookmarkBtn" type="button" aria-label="Bookmark topic">
            <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/></svg>
            <span id="bookmarkLabel">Bookmark</span>
          </button>
          <button class="action-btn" id="resolveBtn" type="button" aria-label="Resolve topic">
            <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 6L9 17l-5-5"/></svg>
            <span id="resolveLabel">Resolve</span>
          </button>
        </div>
      </div>

      <div class="messages" id="messagesList" aria-live="polite"></div>

      <form class="composer" id="replyForm">
        <textarea id="replyInput" rows="1" placeholder="Reply to this topic..." aria-label="Write a reply"></textarea>
        <button class="send-btn" type="submit">Reply</button>
      </form>
    </main>
  </div>
</div>

<script>
const TOPICS = [
  {
    id: 't1',
    stream: 'engineering',
    title: 'Zero-downtime Postgres 17 logical replication cutover',
    unread: 2,
    resolved: false,
    bookmarked: true,
    updated: '14m ago',
    messages: [
      {
        id: 'm1', author: 'Maya Patel', initials: 'MP', color: '#4F46E5', role: 'Staff Infra', time: '09:12',
        text: 'Dry run on staging completed with 140ms max replication lag. I propose we schedule the production cutover for Tuesday 06:00 UTC with a 15-minute write-freeze fallback.',
        reactions: [{ emoji: '🚀', count: 4, reacted: true }, { emoji: '👀', count: 2, reacted: false }]
      },
      {
        id: 'm2', author: 'Devon Brooks', initials: 'DB', color: '#0F766E', role: 'Backend Lead', time: '09:28',
        text: 'Confirmed that pgbouncer connection draining handles the pause cleanly. One note: let us verify sequence sync on `invoice_ledger_id_seq` right before reopening writes.',
        reactions: [{ emoji: '✅', count: 3, reacted: false }]
      },
      {
        id: 'm3', author: 'Maya Patel', initials: 'MP', color: '#4F46E5', role: 'Staff Infra', time: '09:41',
        text: 'Good catch — added `sync_sequences.sql` to step 4 of the runbook and verified it takes <80ms.',
        reactions: [{ emoji: '🔥', count: 2, reacted: false }]
      }
    ]
  },
  {
    id: 't2',
    stream: 'design',
    title: 'Tokenizing warm-sandstone surfaces for dark/light parity',
    unread: 1,
    resolved: false,
    bookmarked: false,
    updated: '42m ago',
    messages: [
      {
        id: 'm4', author: 'Sora Kim', initials: 'SK', color: '#B45309', role: 'Design Systems', time: '08:50',
        text: 'We reduced the neutral palette from 14 grays to 6 semantic surface roles (`canvas`, `elevated`, `sunken`, `hairline`). Contrast ratio on secondary captions now passes 5.2:1.',
        reactions: [{ emoji: '✨', count: 5, reacted: true }]
      },
      {
        id: 'm5', author: 'Liam Chen', initials: 'LC', color: '#7C3AED', role: 'Frontend Eng', time: '09:15',
        text: 'Love the consolidation. Are we keeping `--border-strong` for keyboard focus rings or moving entirely to the indigo outline?',
        reactions: [{ emoji: '👍', count: 2, reacted: false }]
      }
    ]
  },
  {
    id: 't3',
    stream: 'product',
    title: 'Q3 self-serve annual billing proration edge cases',
    unread: 1,
    resolved: false,
    bookmarked: false,
    updated: '2h ago',
    messages: [
      {
        id: 'm6', author: 'Nadia Okafor', initials: 'NO', color: '#BE185D', role: 'Product Mgr', time: '07:35',
        text: 'When a workspace upgrades from Starter Monthly to Pro Annual mid-cycle, Stripe credits unused days automatically, but our in-app invoice preview was showing the full annual charge.',
        reactions: [{ emoji: '🙏', count: 3, reacted: false }]
      },
      {
        id: 'm7', author: 'Devon Brooks', initials: 'DB', color: '#0F766E', role: 'Backend Lead', time: '08:02',
        text: 'Switching the preview modal to `invoices.retrieveUpcoming()` fixes this with exact tax + credit line items.',
        reactions: [{ emoji: '✅', count: 4, reacted: true }]
      }
    ]
  },
  {
    id: 't4',
    stream: 'engineering',
    title: 'CI build cache hit rate dropped to 61% after Node 22 bump',
    unread: 0,
    resolved: true,
    bookmarked: false,
    updated: 'Yesterday',
    messages: [
      {
        id: 'm8', author: 'Liam Chen', initials: 'LC', color: '#7C3AED', role: 'Frontend Eng', time: 'Yesterday',
        text: 'Found it: the lockfile hash key included the minor patch version of pnpm. Pinned cache key to `pnpm-lock.yaml` only — hit rate is back to 94% and median CI time dropped from 6m10s to 2m18s.',
        reactions: [{ emoji: '🎉', count: 7, reacted: true }]
      }
    ]
  },
  {
    id: 't5',
    stream: 'design',
    title: 'Mobile drill-down transitions for split-pane readers',
    unread: 0,
    resolved: false,
    bookmarked: true,
    updated: 'Yesterday',
    messages: [
      {
        id: 'm9', author: 'Sora Kim', initials: 'SK', color: '#B45309', role: 'Design Systems', time: 'Yesterday',
        text: 'On viewports <=820px, tapping a topic should drill directly into the thread with a 44px back button in the sticky header so the composer stays pinned above the keyboard.',
        reactions: [{ emoji: '👍', count: 4, reacted: false }]
      }
    ]
  }
];

const STREAMS = ['all', 'engineering', 'design', 'product', 'bookmarked'];
let activeStream = 'all';
let activeTopicId = 't1';

const splitView = document.getElementById('splitView');
const streamTabs = document.getElementById('streamTabs');
const feedList = document.getElementById('feedList');
const feedSummary = document.getElementById('feedSummary');
const unreadTotal = document.getElementById('unreadTotal');
const threadTitle = document.getElementById('threadTitle');
const threadSub = document.getElementById('threadSub');
const messagesList = document.getElementById('messagesList');
const bookmarkBtn = document.getElementById('bookmarkBtn');
const bookmarkLabel = document.getElementById('bookmarkLabel');
const resolveBtn = document.getElementById('resolveBtn');
const resolveLabel = document.getElementById('resolveLabel');
const replyForm = document.getElementById('replyForm');
const replyInput = document.getElementById('replyInput');

function getVisibleTopics() {
  if (activeStream === 'all') return TOPICS;
  if (activeStream === 'bookmarked') return TOPICS.filter(t => t.bookmarked);
  return TOPICS.filter(t => t.stream === activeStream);
}

function getActiveTopic() {
  return TOPICS.find(t => t.id === activeTopicId) || TOPICS[0];
}

function renderStreams() {
  streamTabs.innerHTML = '';
  STREAMS.forEach(st => {
    const b = document.createElement('button');
    b.type = 'button';
    b.className = 'stream-chip' + (activeStream === st ? ' active' : '');
    b.textContent = st === 'all' ? 'All Streams' : st === 'bookmarked' ? 'Bookmarked' : `#${st}`;
    b.addEventListener('click', () => {
      activeStream = st;
      renderStreams();
      renderFeed();
    });
    streamTabs.appendChild(b);
  });
}

function renderFeed() {
  const list = getVisibleTopics();
  const totalUnread = TOPICS.reduce((acc, t) => acc + t.unread, 0);
  feedSummary.textContent = `${list.length} ${list.length === 1 ? 'topic' : 'topics'}`;
  unreadTotal.textContent = `${totalUnread} unread`;

  feedList.innerHTML = '';
  list.forEach(t => {
    const btn = document.createElement('button');
    btn.type = 'button';
    btn.className = 'topic-item' + (t.id === activeTopicId ? ' active' : '');
    btn.innerHTML = `
      <div class="topic-top">
        <span class="stream-pill">#${t.stream}</span>
        <div class="topic-badges">
          ${t.resolved ? '<span class="resolved-tag">Resolved</span>' : ''}
          ${t.unread > 0 ? `<span class="unread-dot">${t.unread}</span>` : ''}
        </div>
      </div>
      <div class="topic-title">${t.title}</div>
      <div class="topic-meta">
        <span>${t.messages.length} ${t.messages.length === 1 ? 'message' : 'messages'}${t.bookmarked ? ' · ★' : ''}</span>
        <span>${t.updated}</span>
      </div>
    `;
    btn.addEventListener('click', () => openTopic(t.id));
    feedList.appendChild(btn);
  });
}

function openTopic(id) {
  activeTopicId = id;
  const topic = getActiveTopic();
  topic.unread = 0;
  splitView.classList.add('mobile-thread');
  renderFeed();
  renderThread();
}

function renderThread() {
  const topic = getActiveTopic();
  threadTitle.textContent = topic.title;
  threadSub.textContent = `#${topic.stream} · ${topic.messages.length} messages · ${topic.resolved ? 'Resolved' : 'Open'}`;

  bookmarkBtn.classList.toggle('bookmarked', topic.bookmarked);
  bookmarkLabel.textContent = topic.bookmarked ? 'Bookmarked' : 'Bookmark';
  resolveBtn.classList.toggle('resolved', topic.resolved);
  resolveLabel.textContent = topic.resolved ? 'Resolved' : 'Resolve';

  messagesList.innerHTML = '';
  topic.messages.forEach(m => {
    const row = document.createElement('article');
    row.className = 'msg';
    row.innerHTML = `
      <div class="avatar" style="background:${m.color}">${m.initials}</div>
      <div class="msg-body">
        <div class="msg-head">
          <span class="msg-author">${m.author}</span>
          <span class="msg-role">${m.role}</span>
          <span class="msg-time">${m.time}</span>
        </div>
        <div class="msg-text"></div>
        <div class="reactions"></div>
      </div>
    `;
    row.querySelector('.msg-text').textContent = m.text;

    const reactWrap = row.querySelector('.reactions');
    m.reactions.forEach((r) => {
      const rb = document.createElement('button');
      rb.type = 'button';
      rb.className = 'react-btn' + (r.reacted ? ' reacted' : '');
      rb.innerHTML = `<span>${r.emoji}</span><span>${r.count}</span>`;
      rb.addEventListener('click', () => {
        r.reacted = !r.reacted;
        r.count += r.reacted ? 1 : -1;
        renderThread();
      });
      reactWrap.appendChild(rb);
    });

    const addReact = document.createElement('button');
    addReact.type = 'button';
    addReact.className = 'react-btn';
    addReact.textContent = '+ 👍';
    addReact.setAttribute('aria-label', 'Add thumbs up reaction');
    addReact.addEventListener('click', () => {
      const existing = m.reactions.find(r => r.emoji === '👍');
      if (existing) {
        if (!existing.reacted) { existing.reacted = true; existing.count++; }
      } else {
        m.reactions.push({ emoji: '👍', count: 1, reacted: true });
      }
      renderThread();
    });
    reactWrap.appendChild(addReact);

    messagesList.appendChild(row);
  });
}

bookmarkBtn.addEventListener('click', () => {
  const topic = getActiveTopic();
  topic.bookmarked = !topic.bookmarked;
  renderFeed();
  renderThread();
});

resolveBtn.addEventListener('click', () => {
  const topic = getActiveTopic();
  topic.resolved = !topic.resolved;
  renderFeed();
  renderThread();
});

document.getElementById('backBtn').addEventListener('click', () => {
  splitView.classList.remove('mobile-thread');
});

replyForm.addEventListener('submit', (e) => {
  e.preventDefault();
  const text = replyInput.value.trim();
  if (!text) return;
  const topic = getActiveTopic();
  topic.messages.push({
    id: 'm-' + Date.now(),
    author: 'You',
    initials: 'YO',
    color: '#3730A3',
    role: 'Product Eng',
    time: 'Just now',
    text,
    reactions: []
  });
  topic.updated = 'Just now';
  replyInput.value = '';
  renderFeed();
  renderThread();
  messagesList.scrollTop = messagesList.scrollHeight;
});

renderStreams();
renderFeed();
renderThread();
</script>
</body>
</html>
```
