{
  "id": 117,
  "slug": "inline-swipe-row-actions",
  "name": "Inline Swipe-to-Reveal Row Actions",
  "kind": "ui",
  "family": "Gestures & Triage",
  "sourceSite": {
    "name": "Spark Mail",
    "url": "https://sparkmailapp.com",
    "verifiedStatus": 200
  },
  "tagline": "Inbox rows that reveal color-coded Archive, Pin, Snooze, and Delete trays on horizontal swipe, with desktop hover parity.",
  "whyUnique": "Keeps list rows clean and scannable while placing high-frequency triage actions directly beneath each row for effortless thumb swipes.",
  "theme": "light",
  "mobileStrength": "native-first",
  "tags": [
    "swipe-actions",
    "inbox-triage",
    "row-gestures",
    "undo-snackbar",
    "list-ui"
  ],
  "bestFor": [
    "Email & notification inboxes",
    "Task & reminder lists",
    "Support ticket queues",
    "Banking & transaction feeds"
  ],
  "palette": [
    {
      "role": "canvas",
      "hex": "#F6F8FB",
      "name": "Inbox Ice"
    },
    {
      "role": "surface",
      "hex": "#FFFFFF",
      "name": "Message White"
    },
    {
      "role": "ink",
      "hex": "#111827",
      "name": "Slate Ink"
    },
    {
      "role": "accent",
      "hex": "#2563EB",
      "name": "Inbox Cobalt"
    },
    {
      "role": "muted",
      "hex": "#64748B",
      "name": "Meta Slate"
    }
  ],
  "typography": {
    "display": "Plus Jakarta Sans",
    "body": "Inter",
    "mono": "JetBrains Mono",
    "googleFontsUrl": "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500&family=Plus+Jakarta+Sans:wght@700&display=swap",
    "scaleNotes": "Bold unread sender lines (15px), single-line truncated subjects, and crisp 12px timestamps."
  },
  "layoutNotes": "Clean message list with filter tabs (Inbox, Pinned, Snoozed, Archived), layered swipeable rows, and a bottom Undo snackbar.",
  "interactionNotes": "Dragging a row right reveals emerald Archive / amber Pin actions; dragging left reveals indigo Snooze / rose Delete actions, snapping open at threshold or triggering on full swipe, with hover action buttons on desktop.",
  "mobileNotes": "Locks horizontal drag only after clear horizontal intent (dx > dy) so vertical scrolling stays silky smooth.",
  "agentGuardrails": {
    "do": [
      "Always expose equivalent hover/focus action buttons on desktop so mouse and keyboard users never need to drag",
      "Use distinct semantic colors and icons for left vs. right swipe trays (e.g., green Archive vs. red Delete)",
      "Provide an immediate Undo snackbar for every swipe-triggered archive, snooze, or delete"
    ],
    "dont": [
      "Do not allow multiple rows to remain swiped open simultaneously; close the previous row when starting a new swipe",
      "Do not trigger destructive deletes on tiny accidental horizontal nudges"
    ]
  },
  "demoFile": "demos/inline-swipe-row-actions.html",
  "thumbDesktop": "thumbs/inline-swipe-row-actions-desktop.webp",
  "thumbMobile": "thumbs/inline-swipe-row-actions-mobile.webp",
  "urls": {
    "page": "https://templates.michaelpitts.net/t/inline-swipe-row-actions",
    "markdown": "https://templates.michaelpitts.net/t/inline-swipe-row-actions.md",
    "api": "https://templates.michaelpitts.net/api/templates/inline-swipe-row-actions",
    "demo": "https://templates.michaelpitts.net/demos/inline-swipe-row-actions.html",
    "thumbDesktop": "https://templates.michaelpitts.net/thumbs/inline-swipe-row-actions-desktop.webp",
    "thumbMobile": "https://templates.michaelpitts.net/thumbs/inline-swipe-row-actions-mobile.webp"
  },
  "agentPrompt": "Design & build using template #117 \"Inline Swipe-to-Reveal Row Actions\" (ui / Gestures & Triage, light theme).\nFull AI blueprint & standalone starter code: https://templates.michaelpitts.net/t/inline-swipe-row-actions.md\nLive demo: https://templates.michaelpitts.net/demos/inline-swipe-row-actions.html\nReal-world inspiration: Spark Mail (https://sparkmailapp.com)\n\nCore aesthetic: Keeps list rows clean and scannable while placing high-frequency triage actions directly beneath each row for effortless thumb swipes.\nPalette: canvas: #F6F8FB (Inbox Ice), surface: #FFFFFF (Message White), ink: #111827 (Slate Ink), accent: #2563EB (Inbox Cobalt), muted: #64748B (Meta Slate)\nTypography: Display=\"Plus Jakarta Sans\", Body=\"Inter\", Mono=\"JetBrains Mono\"\nLayout: Clean message list with filter tabs (Inbox, Pinned, Snoozed, Archived), layered swipeable rows, and a bottom Undo snackbar.\nInteractions: Dragging a row right reveals emerald Archive / amber Pin actions; dragging left reveals indigo Snooze / rose Delete actions, snapping open at threshold or triggering on full swipe, with hover action buttons on desktop.\nMobile: Locks horizontal drag only after clear horizontal intent (dx > dy) so vertical scrolling stays silky smooth.\n\nGuardrails:\n- DO: Always expose equivalent hover/focus action buttons on desktop so mouse and keyboard users never need to drag\n- DO: Use distinct semantic colors and icons for left vs. right swipe trays (e.g., green Archive vs. red Delete)\n- DO: Provide an immediate Undo snackbar for every swipe-triggered archive, snooze, or delete\n- DON'T: Do not allow multiple rows to remain swiped open simultaneously; close the previous row when starting a new swipe\n- DON'T: Do not trigger destructive deletes on tiny accidental horizontal nudges",
  "sourceCode": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<title>Mailstream — Inline Swipe Row Actions</title>\n<style>\n  :root {\n    --canvas: #F6F8FB;\n    --surface: #FFFFFF;\n    --ink: #111827;\n    --accent: #2563EB;\n    --muted: #64748B;\n    --border: #E2E8F0;\n    --emerald: #059669;\n    --amber: #D97706;\n    --indigo: #4F46E5;\n    --rose: #E11D48;\n    --font: -apple-system, BlinkMacSystemFont, \"Inter\", \"Segoe UI\", system-ui, sans-serif;\n  }\n\n  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }\n\n  body {\n    background: var(--canvas);\n    color: var(--ink);\n    font-family: var(--font);\n    min-height: 100dvh;\n    overflow-x: hidden;\n  }\n\n  .app {\n    max-width: 840px;\n    margin: 0 auto;\n    padding: 18px 14px 96px;\n  }\n\n  @media (min-width: 720px) {\n    .app { padding: 32px 24px 96px; }\n  }\n\n  .topbar {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    gap: 12px;\n    margin-bottom: 16px;\n  }\n\n  .topbar h1 {\n    font-size: 24px;\n    font-weight: 750;\n    letter-spacing: -0.02em;\n  }\n\n  .topbar p {\n    font-size: 13px;\n    color: var(--muted);\n    margin-top: 2px;\n  }\n\n  .restore-btn {\n    min-height: 44px;\n    padding: 0 14px;\n    border-radius: 10px;\n    border: 1px solid var(--border);\n    background: var(--surface);\n    color: var(--ink);\n    font-size: 13px;\n    font-weight: 600;\n    cursor: pointer;\n    flex-shrink: 0;\n  }\n  .restore-btn:hover { border-color: var(--accent); color: var(--accent); }\n\n  /* Filter tabs */\n  .tabs {\n    display: flex;\n    gap: 6px;\n    overflow-x: auto;\n    scrollbar-width: none;\n    margin-bottom: 14px;\n  }\n  .tabs::-webkit-scrollbar { display: none; }\n\n  .tab-btn {\n    min-height: 44px;\n    padding: 0 14px;\n    border-radius: 11px;\n    border: 1px solid transparent;\n    background: transparent;\n    color: var(--muted);\n    font-size: 13px;\n    font-weight: 600;\n    cursor: pointer;\n    display: inline-flex;\n    align-items: center;\n    gap: 7px;\n    white-space: nowrap;\n  }\n\n  .tab-btn[aria-selected=\"true\"] {\n    background: var(--surface);\n    color: var(--ink);\n    border-color: var(--border);\n    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);\n  }\n\n  .tab-count {\n    font-size: 11px;\n    padding: 1px 7px;\n    border-radius: 999px;\n    background: #EFF6FF;\n    color: var(--accent);\n  }\n\n  /* Gesture legend */\n  .gesture-hint {\n    display: flex;\n    justify-content: space-between;\n    gap: 8px;\n    font-size: 11px;\n    font-weight: 600;\n    color: var(--muted);\n    padding: 0 4px 8px;\n    flex-wrap: wrap;\n  }\n  .gesture-hint .r { color: var(--emerald); }\n  .gesture-hint .l { color: var(--rose); }\n\n  /* Inbox container */\n  .inbox-list {\n    background: var(--surface);\n    border: 1px solid var(--border);\n    border-radius: 16px;\n    overflow: hidden;\n    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);\n  }\n\n  .swipe-row {\n    position: relative;\n    overflow: hidden;\n    border-bottom: 1px solid var(--border);\n    user-select: none;\n    -webkit-user-select: none;\n  }\n  .swipe-row:last-child { border-bottom: none; }\n\n  /* Revealed action trays underneath */\n  .tray {\n    position: absolute;\n    top: 0;\n    bottom: 0;\n    display: flex;\n    align-items: stretch;\n  }\n  .tray-left { left: 0; }\n  .tray-right { right: 0; }\n\n  .tray-btn {\n    min-width: 78px;\n    border: none;\n    color: #fff;\n    font-family: var(--font);\n    font-size: 12px;\n    font-weight: 700;\n    cursor: pointer;\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    justify-content: center;\n    gap: 3px;\n    padding: 0 10px;\n  }\n  .tray-btn.archive { background: var(--emerald); }\n  .tray-btn.pin { background: var(--amber); }\n  .tray-btn.snooze { background: var(--indigo); }\n  .tray-btn.delete { background: var(--rose); }\n\n  /* Draggable Foreground Row */\n  .row-fg {\n    position: relative;\n    z-index: 2;\n    background: var(--surface);\n    padding: 13px 16px;\n    display: flex;\n    align-items: flex-start;\n    gap: 12px;\n    touch-action: pan-y;\n    cursor: grab;\n    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), background 0.15s;\n  }\n  .row-fg.dragging { transition: none; cursor: grabbing; }\n  .row-fg:hover { background: #FAFBFD; }\n\n  .avatar {\n    width: 38px;\n    height: 38px;\n    border-radius: 50%;\n    font-size: 13px;\n    font-weight: 750;\n    color: #fff;\n    display: grid;\n    place-items: center;\n    flex-shrink: 0;\n    margin-top: 2px;\n  }\n\n  .msg-body {\n    flex: 1;\n    min-width: 0;\n  }\n\n  .msg-top {\n    display: flex;\n    align-items: baseline;\n    justify-content: space-between;\n    gap: 8px;\n  }\n\n  .sender {\n    font-size: 14px;\n    font-weight: 600;\n    color: var(--ink);\n    display: inline-flex;\n    align-items: center;\n    gap: 6px;\n    white-space: nowrap;\n    overflow: hidden;\n    text-overflow: ellipsis;\n  }\n\n  .unread-dot {\n    width: 8px;\n    height: 8px;\n    border-radius: 50%;\n    background: var(--accent);\n    flex-shrink: 0;\n  }\n\n  .pin-badge {\n    font-size: 11px;\n    color: var(--amber);\n    font-weight: 700;\n  }\n\n  .time {\n    font-size: 12px;\n    color: var(--muted);\n    white-space: nowrap;\n    flex-shrink: 0;\n  }\n\n  .subject {\n    font-size: 14px;\n    color: var(--ink);\n    margin-top: 2px;\n    white-space: nowrap;\n    overflow: hidden;\n    text-overflow: ellipsis;\n  }\n  .swipe-row.unread .subject { font-weight: 700; }\n\n  .snippet {\n    font-size: 13px;\n    color: var(--muted);\n    margin-top: 2px;\n    white-space: nowrap;\n    overflow: hidden;\n    text-overflow: ellipsis;\n  }\n\n  /* Desktop hover quick actions */\n  .hover-actions {\n    display: none;\n    position: absolute;\n    right: 12px;\n    top: 50%;\n    transform: translateY(-50%);\n    gap: 4px;\n    background: #FAFBFD;\n    padding: 4px;\n    border-radius: 10px;\n    border: 1px solid var(--border);\n    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);\n  }\n\n  @media (hover: hover) and (min-width: 720px) {\n    .row-fg:hover .hover-actions { display: flex; }\n  }\n\n  .quick-act {\n    min-width: 36px;\n    min-height: 36px;\n    padding: 0 9px;\n    border: none;\n    border-radius: 7px;\n    background: transparent;\n    color: var(--muted);\n    font-size: 11px;\n    font-weight: 700;\n    cursor: pointer;\n  }\n  .quick-act:hover { background: #EEF2F6; color: var(--ink); }\n  .quick-act.del:hover { background: #FFF1F2; color: var(--rose); }\n  .quick-act.arc:hover { background: #ECFDF5; color: var(--emerald); }\n\n  .empty-inbox {\n    padding: 48px 20px;\n    text-align: center;\n    color: var(--muted);\n    font-size: 14px;\n  }\n\n  /* Undo Snackbar */\n  .snackbar {\n    position: fixed;\n    left: 50%;\n    bottom: 20px;\n    transform: translate(-50%, 90px);\n    background: #111827;\n    color: #fff;\n    padding: 10px 12px 10px 16px;\n    border-radius: 14px;\n    display: flex;\n    align-items: center;\n    gap: 14px;\n    font-size: 13px;\n    font-weight: 500;\n    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.32);\n    z-index: 50;\n    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);\n    max-width: calc(100% - 28px);\n  }\n  .snackbar.show { transform: translate(-50%, 0); }\n\n  .undo-btn {\n    min-height: 36px;\n    padding: 0 12px;\n    border: none;\n    border-radius: 8px;\n    background: var(--accent);\n    color: #fff;\n    font-size: 12px;\n    font-weight: 700;\n    cursor: pointer;\n  }\n</style>\n</head>\n<body>\n  <div class=\"app\">\n    <header class=\"topbar\">\n      <div>\n        <h1>Inbox</h1>\n        <p>Swipe rows right to Archive/Pin, or left to Snooze/Delete</p>\n      </div>\n      <button class=\"restore-btn\" id=\"resetBtn\">Reset Demo</button>\n    </header>\n\n    <nav class=\"tabs\" role=\"tablist\" aria-label=\"Mailbox folders\">\n      <button class=\"tab-btn\" role=\"tab\" data-tab=\"inbox\" aria-selected=\"true\">Inbox <span class=\"tab-count\" id=\"cInbox\">0</span></button>\n      <button class=\"tab-btn\" role=\"tab\" data-tab=\"pinned\" aria-selected=\"false\">Pinned <span class=\"tab-count\" id=\"cPinned\">0</span></button>\n      <button class=\"tab-btn\" role=\"tab\" data-tab=\"snoozed\" aria-selected=\"false\">Snoozed <span class=\"tab-count\" id=\"cSnoozed\">0</span></button>\n      <button class=\"tab-btn\" role=\"tab\" data-tab=\"archived\" aria-selected=\"false\">Archived <span class=\"tab-count\" id=\"cArchived\">0</span></button>\n    </nav>\n\n    <div class=\"gesture-hint\">\n      <span class=\"r\">→ Drag right: Archive · Pin</span>\n      <span class=\"l\">← Drag left: Snooze · Delete</span>\n    </div>\n\n    <main class=\"inbox-list\" id=\"inboxList\"></main>\n  </div>\n\n  <div class=\"snackbar\" id=\"snackbar\" role=\"status\" aria-live=\"polite\">\n    <span id=\"snackText\">Archived conversation</span>\n    <button class=\"undo-btn\" id=\"undoBtn\">Undo</button>\n  </div>\n\n<script>\n(() => {\n  const INITIAL_MAIL = [\n    { id: 1, sender: 'Maya Lin-Sato', initials: 'ML', color: '#2563EB', time: '9:42 AM', subject: 'Updated typography tokens for v3.2 release', snippet: 'Pushed the final optical scale adjustments to Figma — ready for engineering sign-off before noon.', unread: true, pinned: true, status: 'inbox' },\n    { id: 2, sender: 'Fastmail Security', initials: 'FS', color: '#059669', time: '9:15 AM', subject: 'New passkey enrolled on MacBook Pro', snippet: 'A hardware-backed WebAuthn passkey was added to your account from Seattle, WA.', unread: true, pinned: false, status: 'inbox' },\n    { id: 3, sender: 'Devon Morales', initials: 'DM', color: '#7C3AED', time: '8:50 AM', subject: 'Re: Friday architecture review agenda', snippet: 'Let us trim the migration slide deck to 10 minutes so we have room for Q&A on cache invalidation.', unread: false, pinned: false, status: 'inbox' },\n    { id: 4, sender: 'Linear Digest', initials: 'LD', color: '#4F46E5', time: 'Yesterday', subject: '4 issues moved to In Review in Mobile Core', snippet: 'Swipe physics polish, keyboard shortcut conflict fix, and offline queue retry backoff.', unread: false, pinned: false, status: 'inbox' },\n    { id: 5, sender: 'Claire Beaumont', initials: 'CB', color: '#D97706', time: 'Yesterday', subject: 'Invoice #4092 — Studio Sound Mixing', snippet: 'Attached is the final PDF invoice for the launch video mastering session. Net-30 terms apply.', unread: true, pinned: false, status: 'inbox' },\n    { id: 6, sender: 'Kenji Watanabe', initials: 'KW', color: '#0891B2', time: 'Mon', subject: 'Coffee near Pioneer Square next week?', snippet: 'In town Tuesday through Thursday for the design systems summit—would love to catch up.', unread: false, pinned: false, status: 'inbox' },\n    { id: 7, sender: 'Stripe Billing', initials: 'SB', color: '#334155', time: 'Sun', subject: 'Your monthly cloud infrastructure receipt', snippet: 'Payment of $148.00 succeeded for workspace billing period ending this Sunday.', unread: false, pinned: false, status: 'archived' }\n  ];\n\n  let messages = structuredClone(INITIAL_MAIL);\n  let activeTab = 'inbox';\n  let lastUndo = null;\n  let openRowReset = null;\n  let snackTimer = null;\n\n  const listEl = document.getElementById('inboxList');\n  const snackbar = document.getElementById('snackbar');\n  const snackText = document.getElementById('snackText');\n\n  function showUndo(label, undoFn) {\n    lastUndo = undoFn;\n    snackText.textContent = label;\n    snackbar.classList.add('show');\n    clearTimeout(snackTimer);\n    snackTimer = setTimeout(() => snackbar.classList.remove('show'), 4500);\n  }\n\n  function applyAction(id, action) {\n    const msg = messages.find(m => m.id === id);\n    if (!msg) return;\n    const prev = { status: msg.status, pinned: msg.pinned };\n\n    if (action === 'archive') {\n      msg.status = msg.status === 'archived' ? 'inbox' : 'archived';\n      showUndo(msg.status === 'archived' ? `Archived \"${msg.sender}\"` : `Moved \"${msg.sender}\" to Inbox`, () => {\n        Object.assign(msg, prev); render();\n      });\n    } else if (action === 'pin') {\n      msg.pinned = !msg.pinned;\n      showUndo(msg.pinned ? `Pinned \"${msg.sender}\"` : `Unpinned \"${msg.sender}\"`, () => {\n        Object.assign(msg, prev); render();\n      });\n    } else if (action === 'snooze') {\n      msg.status = 'snoozed';\n      showUndo(`Snoozed \"${msg.sender}\" until tomorrow 9:00 AM`, () => {\n        Object.assign(msg, prev); render();\n      });\n    } else if (action === 'delete') {\n      const idx = messages.findIndex(m => m.id === id);\n      const removed = messages.splice(idx, 1)[0];\n      showUndo(`Deleted \"${removed.sender}\"`, () => {\n        messages.splice(idx, 0, removed); render();\n      });\n    }\n    render();\n  }\n\n  function attachSwipe(rowEl, fgEl, msgId) {\n    let startX = 0, startY = 0, baseOffset = 0, currentX = 0;\n    let mode = null; // 'h' or 'v'\n    const SNAP_WIDTH = 156;\n    const FULL_COMMIT = 205;\n\n    const setX = (x, animate) => {\n      fgEl.classList.toggle('dragging', !animate);\n      fgEl.style.transform = `translate3d(${x}px, 0, 0)`;\n      currentX = x;\n    };\n\n    const closeSelf = () => setX(0, true);\n\n    fgEl.addEventListener('pointerdown', e => {\n      if (e.target.closest('button')) return;\n      if (openRowReset && openRowReset !== closeSelf) {\n        openRowReset();\n        openRowReset = null;\n      }\n      startX = e.clientX;\n      startY = e.clientY;\n      baseOffset = currentX;\n      mode = null;\n      fgEl.setPointerCapture(e.pointerId);\n    });\n\n    fgEl.addEventListener('pointermove', e => {\n      if (!fgEl.hasPointerCapture(e.pointerId)) return;\n      const dx = e.clientX - startX;\n      const dy = e.clientY - startY;\n\n      if (!mode) {\n        if (Math.abs(dx) > 8 && Math.abs(dx) > Math.abs(dy)) mode = 'h';\n        else if (Math.abs(dy) > 8) { mode = 'v'; return; }\n        else return;\n      }\n      if (mode !== 'h') return;\n\n      let next = baseOffset + dx;\n      // Soft resistance past SNAP_WIDTH\n      if (next > SNAP_WIDTH) next = SNAP_WIDTH + (next - SNAP_WIDTH) * 0.45;\n      if (next < -SNAP_WIDTH) next = -SNAP_WIDTH + (next + SNAP_WIDTH) * 0.45;\n      setX(next, false);\n    });\n\n    const endDrag = () => {\n      if (mode !== 'h') return;\n      mode = null;\n\n      if (currentX >= FULL_COMMIT) {\n        setX(360, true);\n        setTimeout(() => applyAction(msgId, 'archive'), 140);\n      } else if (currentX <= -FULL_COMMIT) {\n        setX(-360, true);\n        setTimeout(() => applyAction(msgId, 'delete'), 140);\n      } else if (currentX >= 68) {\n        setX(SNAP_WIDTH, true);\n        openRowReset = closeSelf;\n      } else if (currentX <= -68) {\n        setX(-SNAP_WIDTH, true);\n        openRowReset = closeSelf;\n      } else {\n        closeSelf();\n      }\n    };\n\n    fgEl.addEventListener('pointerup', endDrag);\n    fgEl.addEventListener('pointercancel', endDrag);\n  }\n\n  function render() {\n    document.getElementById('cInbox').textContent = messages.filter(m => m.status === 'inbox').length;\n    document.getElementById('cPinned').textContent = messages.filter(m => m.pinned && m.status !== 'archived').length;\n    document.getElementById('cSnoozed').textContent = messages.filter(m => m.status === 'snoozed').length;\n    document.getElementById('cArchived').textContent = messages.filter(m => m.status === 'archived').length;\n\n    const visible = messages.filter(m => {\n      if (activeTab === 'inbox') return m.status === 'inbox';\n      if (activeTab === 'pinned') return m.pinned && m.status !== 'archived';\n      if (activeTab === 'snoozed') return m.status === 'snoozed';\n      if (activeTab === 'archived') return m.status === 'archived';\n      return true;\n    });\n\n    listEl.innerHTML = '';\n    if (visible.length === 0) {\n      listEl.innerHTML = `<div class=\"empty-inbox\">All clear in <strong>${activeTab}</strong>.</div>`;\n      return;\n    }\n\n    visible.forEach(msg => {\n      const row = document.createElement('div');\n      row.className = `swipe-row${msg.unread ? ' unread' : ''}`;\n      row.innerHTML = `\n        <div class=\"tray tray-left\">\n          <button class=\"tray-btn archive\" data-act=\"archive\">${msg.status === 'archived' ? 'Inbox' : 'Archive'}</button>\n          <button class=\"tray-btn pin\" data-act=\"pin\">${msg.pinned ? 'Unpin' : 'Pin'}</button>\n        </div>\n        <div class=\"tray tray-right\">\n          <button class=\"tray-btn snooze\" data-act=\"snooze\">Snooze</button>\n          <button class=\"tray-btn delete\" data-act=\"delete\">Delete</button>\n        </div>\n        <div class=\"row-fg\">\n          <div class=\"avatar\" style=\"background:${msg.color}\">${msg.initials}</div>\n          <div class=\"msg-body\">\n            <div class=\"msg-top\">\n              <span class=\"sender\">\n                ${msg.unread ? '<span class=\"unread-dot\" aria-label=\"Unread\"></span>' : ''}\n                ${msg.sender}\n                ${msg.pinned ? '<span class=\"pin-badge\">★</span>' : ''}\n              </span>\n              <span class=\"time\">${msg.time}</span>\n            </div>\n            <div class=\"subject\">${msg.subject}</div>\n            <div class=\"snippet\">${msg.snippet}</div>\n          </div>\n          <div class=\"hover-actions\">\n            <button class=\"quick-act arc\" data-act=\"archive\">${msg.status === 'archived' ? 'Inbox' : 'Archive'}</button>\n            <button class=\"quick-act\" data-act=\"pin\">${msg.pinned ? 'Unpin' : 'Pin'}</button>\n            <button class=\"quick-act\" data-act=\"snooze\">Snooze</button>\n            <button class=\"quick-act del\" data-act=\"delete\">Delete</button>\n          </div>\n        </div>\n      `;\n\n      row.querySelectorAll('[data-act]').forEach(btn => {\n        btn.addEventListener('click', e => {\n          e.stopPropagation();\n          applyAction(msg.id, btn.dataset.act);\n        });\n      });\n\n      const fg = row.querySelector('.row-fg');\n      fg.addEventListener('click', () => {\n        if (msg.unread) { msg.unread = false; render(); }\n      });\n\n      attachSwipe(row, fg, msg.id);\n      listEl.appendChild(row);\n    });\n  }\n\n  document.querySelectorAll('.tab-btn').forEach(btn => {\n    btn.addEventListener('click', () => {\n      document.querySelectorAll('.tab-btn').forEach(b => b.setAttribute('aria-selected', 'false'));\n      btn.setAttribute('aria-selected', 'true');\n      activeTab = btn.dataset.tab;\n      render();\n    });\n  });\n\n  document.getElementById('undoBtn').addEventListener('click', () => {\n    if (lastUndo) {\n      lastUndo();\n      lastUndo = null;\n      snackbar.classList.remove('show');\n    }\n  });\n\n  document.getElementById('resetBtn').addEventListener('click', () => {\n    messages = structuredClone(INITIAL_MAIL);\n    activeTab = 'inbox';\n    document.querySelectorAll('.tab-btn').forEach(b => b.setAttribute('aria-selected', String(b.dataset.tab === 'inbox')));\n    snackbar.classList.remove('show');\n    render();\n  });\n\n  render();\n})();\n</script>\n</body>\n</html>\n"
}
