# #015 — UbuWeb Raw Avant-Garde Archive

> Calm anti-algorithmic avant-garde archive: stark chalk white, 1px hairline block cells, and open-index markers.

## Metadata

- **Index**: #015
- **Slug**: `ubuweb-avant-archive`
- **Kind**: `style`
- **Family**: Raw-Web & Archival
- **Theme**: `light`
- **Mobile Strength**: `high`
- **Tags**: `raw-web`, `avant-garde`, `anti-algorithmic`, `minimal-grid`, `archival`, `utilitarian`
- **Best For**: Avant-garde sound & film archives, Research repositories & digital libraries, Academic & art reference catalogs, Calm collaborative knowledge gardens
- **Real-World Inspiration**: [UbuWeb](https://www.ubu.com)
- **Detail Page**: https://templates.michaelpitts.net/t/ubuweb-avant-archive
- **Live Demo**: https://templates.michaelpitts.net/demos/ubuweb-avant-archive.html
- **JSON API**: https://templates.michaelpitts.net/api/templates/ubuweb-avant-archive

## Why This Aesthetic Is Unique

Replaces noisy algorithmic feeds with a meditative, utilitarian archival index: crisp 1px-bordered blocks of sound poetry, film notes, and diagrams organized into open collections with zero commercial clutter.

## Color Palette

| Role | Name | Hex |
|------|------|-----|
| `canvas` | Chalk White | `#FFFFFF` |
| `surface` | Block Matte | `#F7F7F7` |
| `ink` | Graphite Ink | `#1A1A1A` |
| `accent` | Open Archive Green | `#17AC10` |
| `muted` | Catalog Meta Gray | `#6D6D6D` |

## Typography

- **Display**: `Inter, -apple-system, BlinkMacSystemFont, sans-serif`
- **Body**: `Inter, -apple-system, BlinkMacSystemFont, sans-serif`
- **Mono**: `IBM Plex Mono, ui-monospace, monospace`
- **Scale Notes**: Restrained, uniform sans scale (13-18px) with zero oversized hero theatrics; monospace reserved for catalog IDs, counts, and timestamps.
- **Google Fonts**: https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Inter:wght@400;500;600&display=swap
  ```html
  <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Inter:wght@400;500;600&display=swap">
  ```

## Layout Architecture

Single-row utilitarian breadcrumb header with search input, collection metadata bar, and a clean 4-column square archival block grid mixing text notes, inline SVG diagrams, and linked dossiers.

## Interaction & Micro-Motion Rules

Live catalog/block search filter, block-type filter pills (All, Text, Diagram, Channel), interactive '+ Connect Block' composer modal that appends a real new archival block to the grid, and detail inspector.

## Mobile & Responsive Rules

4-column block grid adapts cleanly to 1-column or 2-column square cards on 390px viewports with >=44px connect and filter controls.

## Agent Guardrails

### DO
- Keep every archival block in a disciplined 1px #D8D8D8 frame with generous inner breathing room
- Use Open Archive Green (#17AC10) sparingly to signal open public collections
- Avoid vanity metrics, likes, or algorithmic recommendation banners

### DON'T
- Do not add loud hero sections, promotional popups, or heavy drop shadows
- Do not use decorative color gradients

## Complete Standalone Starter Code

File: `demos/ubuweb-avant-archive.html`

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>INDEX.NA — Quiet Research Channels &amp; Archival Blocks</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&family=IBM+Plex+Mono:wght@400;500&display=swap" rel="stylesheet">
  <style>
    :root {
      --canvas: #FFFFFF;
      --surface: #F7F7F7;
      --ink: #1A1A1A;
      --accent: #17AC10;
      --muted: #6D6D6D;
      --line: #D8D8D8;
      --line-hover: #999999;
      --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    }

    *, *::before, *::after {
      box-sizing: border-box;
    }

    html, body {
      margin: 0;
      padding: 0;
      background: var(--canvas);
      color: var(--ink);
      font-family: var(--font-sans);
      font-size: 14px;
      line-height: 1.5;
      overflow-x: hidden;
      -webkit-font-smoothing: antialiased;
    }

    /* Quiet Header Bar */
    .topbar {
      position: sticky;
      top: 0;
      z-index: 40;
      background: var(--canvas);
      border-bottom: 1px solid var(--line);
    }

    .topbar-inner {
      max-width: 1280px;
      margin: 0 auto;
      padding: 0.75rem 1.25rem;
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 0.85rem;
    }

    .wordmark {
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      font-weight: 600;
      font-size: 0.98rem;
      letter-spacing: -0.01em;
      color: var(--ink);
      text-decoration: none;
    }

    .dots-mark {
      display: inline-grid;
      grid-template-columns: repeat(2, 6px);
      gap: 3px;
    }

    .dots-mark span {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: var(--ink);
    }

    .search-wrap {
      flex: 1;
      min-width: 180px;
      max-width: 440px;
    }

    .search-field {
      width: 100%;
      min-height: 44px;
      padding: 0.5rem 0.8rem;
      background: var(--surface);
      border: 1px solid var(--line);
      font-family: var(--font-sans);
      font-size: 0.9rem;
      color: var(--ink);
    }

    .search-field:focus {
      outline: none;
      border-color: var(--ink);
      background: var(--canvas);
    }

    .connect-btn {
      margin-left: auto;
      min-height: 44px;
      padding: 0.5rem 1rem;
      background: var(--canvas);
      border: 1px solid var(--ink);
      color: var(--ink);
      font-family: var(--font-sans);
      font-weight: 500;
      font-size: 0.88rem;
      cursor: pointer;
      transition: background-color 0.12s ease, color 0.12s ease;
    }

    .connect-btn:hover {
      background: var(--ink);
      color: var(--canvas);
    }

    /* Main Container */
    .container {
      max-width: 1280px;
      margin: 0 auto;
      padding: 2rem 1.25rem 4rem;
    }

    .channel-header {
      display: flex;
      flex-wrap: wrap;
      align-items: baseline;
      justify-content: space-between;
      gap: 1rem;
      padding-bottom: 1.25rem;
      border-bottom: 1px solid var(--line);
      margin-bottom: 1.5rem;
    }

    .channel-header h1 {
      margin: 0;
      font-size: 1.35rem;
      font-weight: 500;
      letter-spacing: -0.02em;
    }

    .channel-sub {
      margin: 0.3rem 0 0;
      color: var(--muted);
      font-size: 0.88rem;
      max-width: 62ch;
    }

    .meta-mono {
      font-family: var(--font-mono);
      font-size: 0.78rem;
      color: var(--muted);
    }

    /* Channel Filter Strip */
    .channel-strip {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      margin-bottom: 2rem;
    }

    .chan-pill {
      min-height: 44px;
      padding: 0.45rem 0.85rem;
      background: var(--canvas);
      border: 1px solid var(--line);
      color: var(--ink);
      font-family: var(--font-sans);
      font-size: 0.86rem;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 0.45rem;
    }

    .chan-pill:hover {
      border-color: var(--line-hover);
      background: var(--surface);
    }

    .chan-pill.active {
      border-color: var(--ink);
      background: var(--surface);
      font-weight: 600;
    }

    .status-dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: var(--accent);
      flex-shrink: 0;
    }

    .status-dot.closed {
      background: var(--ink);
    }

    .pill-count {
      font-family: var(--font-mono);
      font-size: 0.74rem;
      color: var(--muted);
    }

    /* Structural Block Grid */
    .blocks-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 1.35rem;
    }

    .block-card {
      display: flex;
      flex-direction: column;
      gap: 0.55rem;
      cursor: pointer;
    }

    .block-frame {
      aspect-ratio: 1 / 1;
      border: 1px solid var(--line);
      background: var(--surface);
      padding: 1rem;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      overflow: hidden;
      transition: border-color 0.14s ease, background-color 0.14s ease;
    }

    .block-card:hover .block-frame {
      border-color: var(--ink);
      background: var(--canvas);
    }

    .block-frame.channel-card-frame {
      border-color: var(--accent);
      background: var(--canvas);
      justify-content: center;
      align-items: flex-start;
      gap: 0.4rem;
    }

    .block-frame.channel-card-frame:hover {
      background: #F4FBF3;
    }

    .block-quote {
      margin: 0;
      font-size: 0.92rem;
      line-height: 1.55;
      color: var(--ink);
      overflow: hidden;
      display: -webkit-box;
      -webkit-line-clamp: 7;
      -webkit-box-orient: vertical;
    }

    .block-link-url {
      font-family: var(--font-mono);
      font-size: 0.74rem;
      color: var(--muted);
      word-break: break-all;
    }

    .block-svg-wrap {
      flex: 1;
      display: grid;
      place-items: center;
    }

    .block-svg-wrap svg {
      width: 100%;
      height: 100%;
      max-height: 190px;
      display: block;
    }

    .block-caption {
      display: flex;
      flex-direction: column;
      gap: 0.15rem;
    }

    .block-title {
      font-size: 0.86rem;
      font-weight: 500;
      color: var(--ink);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .block-meta {
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-family: var(--font-mono);
      font-size: 0.72rem;
      color: var(--muted);
    }

    .conn-badge {
      color: var(--accent);
    }

    .empty-msg {
      padding: 3rem 1rem;
      text-align: center;
      border: 1px solid var(--line);
      background: var(--surface);
      color: var(--muted);
      font-family: var(--font-mono);
      font-size: 0.84rem;
    }

    /* Modals (Connect Composer & Block Reader) */
    .modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(255, 255, 255, 0.88);
      z-index: 70;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 1rem;
    }

    .modal-overlay.open {
      display: flex;
    }

    .modal-panel {
      width: min(520px, 100%);
      max-height: 88vh;
      overflow-y: auto;
      background: var(--canvas);
      border: 1px solid var(--ink);
      padding: 1.35rem;
    }

    .modal-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-bottom: 0.85rem;
      border-bottom: 1px solid var(--line);
      margin-bottom: 1rem;
    }

    .modal-head h2 {
      margin: 0;
      font-size: 1.05rem;
      font-weight: 600;
    }

    .icon-close {
      min-width: 44px;
      min-height: 44px;
      background: var(--canvas);
      border: 1px solid var(--line);
      font-size: 1.15rem;
      cursor: pointer;
      color: var(--ink);
    }

    .form-field {
      margin-bottom: 0.9rem;
    }

    .form-field label {
      display: block;
      font-family: var(--font-mono);
      font-size: 0.76rem;
      color: var(--muted);
      margin-bottom: 0.3rem;
      text-transform: uppercase;
    }

    .form-field input,
    .form-field select,
    .form-field textarea {
      width: 100%;
      min-height: 44px;
      padding: 0.55rem 0.7rem;
      border: 1px solid var(--line);
      background: var(--surface);
      font-family: var(--font-sans);
      font-size: 0.9rem;
      color: var(--ink);
    }

    .form-field textarea {
      min-height: 110px;
      resize: vertical;
    }

    .form-actions {
      display: flex;
      justify-content: flex-end;
      gap: 0.6rem;
      margin-top: 1rem;
    }

    .btn-quiet {
      min-height: 44px;
      padding: 0 1rem;
      background: var(--canvas);
      border: 1px solid var(--line);
      color: var(--ink);
      font-size: 0.88rem;
      cursor: pointer;
    }

    .btn-quiet.primary {
      border-color: var(--accent);
      color: var(--accent);
      font-weight: 600;
    }

    .btn-quiet.primary:hover {
      background: var(--accent);
      color: var(--canvas);
    }

    .reader-content {
      border: 1px solid var(--line);
      background: var(--surface);
      padding: 1rem;
      margin-bottom: 1rem;
      white-space: pre-wrap;
      font-size: 0.94rem;
      line-height: 1.6;
    }

    footer {
      max-width: 1280px;
      margin: 0 auto;
      border-top: 1px solid var(--line);
      padding: 1.25rem;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      gap: 0.75rem;
      font-family: var(--font-mono);
      font-size: 0.76rem;
      color: var(--muted);
    }

    /* Responsive */
    @media (max-width: 1024px) {
      .blocks-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }
    }

    @media (max-width: 720px) {
      .blocks-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
      }
      .topbar-inner {
        padding: 0.65rem 1rem;
      }
      .connect-btn {
        margin-left: 0;
        width: 100%;
      }
      .search-wrap {
        max-width: none;
        width: 100%;
      }
    }

    @media (max-width: 460px) {
      .blocks-grid {
        grid-template-columns: 1fr;
      }
      .block-frame {
        aspect-ratio: 4 / 3;
      }
    }
  </style>
</head>
<body>
  <header class="topbar">
    <div class="topbar-inner">
      <a href="#top" class="wordmark">
        <span class="dots-mark" aria-hidden="true"><span></span><span></span><span></span><span></span></span>
        <span>INDEX.NA</span>
      </a>
      <div class="search-wrap">
        <input type="search" id="searchInput" class="search-field" placeholder="Filter blocks, notes, diagrams, channels..." aria-label="Filter archival blocks">
      </div>
      <button type="button" class="connect-btn" id="openComposerBtn">+ Connect Block</button>
    </div>
  </header>

  <main class="container" id="top">
    <section class="channel-header">
      <div>
        <h1 id="activeChannelTitle">All Research Channels</h1>
        <p class="channel-sub" id="activeChannelDesc">A calm, ad-free index of connected ideas, architectural sketches, reading excerpts, and slow-web references.</p>
      </div>
      <div class="meta-mono" id="totalStats">4 channels &bull; 10 blocks</div>
    </section>

    <div class="channel-strip" id="channelStrip" role="tablist" aria-label="Filter by channel"></div>

    <section class="blocks-grid" id="blocksGrid" aria-label="Archival blocks"></section>
    <div class="empty-msg" id="emptyMsg" hidden>0 blocks found for this query. Try another keyword or connect a new block.</div>
  </main>

  <footer>
    <span>INDEX.NA &mdash; CALM ARCHIVAL NETWORK</span>
    <span>NO ALGORITHMIC FEED &bull; CHRONOLOGICAL CONNECTIONS</span>
  </footer>

  <!-- Connect Block Composer Modal -->
  <div class="modal-overlay" id="composerModal" role="dialog" aria-modal="true" aria-labelledby="composerHeading">
    <div class="modal-panel">
      <div class="modal-head">
        <h2 id="composerHeading">Connect a New Block</h2>
        <button type="button" class="icon-close" id="closeComposerBtn" aria-label="Close composer">&times;</button>
      </div>
      <form id="composerForm">
        <div class="form-field">
          <label for="blockChannel">Target Channel</label>
          <select id="blockChannel" required></select>
        </div>
        <div class="form-field">
          <label for="blockKind">Block Type</label>
          <select id="blockKind">
            <option value="text">Text Excerpt / Note</option>
            <option value="link">Web Reference / Link</option>
          </select>
        </div>
        <div class="form-field">
          <label for="blockTitleInput">Title</label>
          <input type="text" id="blockTitleInput" placeholder="e.g. Pattern Language Note #159" required maxlength="80">
        </div>
        <div class="form-field">
          <label for="blockBodyInput">Content or URL</label>
          <textarea id="blockBodyInput" placeholder="Write a quiet note, quote, or reference URL..." required></textarea>
        </div>
        <div class="form-actions">
          <button type="button" class="btn-quiet" id="cancelComposerBtn">Cancel</button>
          <button type="submit" class="btn-quiet primary">Connect Block</button>
        </div>
      </form>
    </div>
  </div>

  <!-- Block Reader Modal -->
  <div class="modal-overlay" id="readerModal" role="dialog" aria-modal="true" aria-labelledby="readerTitle">
    <div class="modal-panel">
      <div class="modal-head">
        <h2 id="readerTitle">Block</h2>
        <button type="button" class="icon-close" id="closeReaderBtn" aria-label="Close block reader">&times;</button>
      </div>
      <div class="meta-mono" id="readerMeta" style="margin-bottom:0.85rem;"></div>
      <div class="reader-content" id="readerContent"></div>
      <div class="form-actions">
        <button type="button" class="btn-quiet" id="closeReaderFootBtn">Done</button>
      </div>
    </div>
  </div>

  <script>
    (function () {
      const CHANNELS = [
        {
          id: 'quiet-interfaces',
          name: 'Quiet Interfaces',
          open: true,
          author: 'Mina Sato',
          desc: 'Software that respects attention: hairline grids, restrained ink, and predictable state.'
        },
        {
          id: 'civic-signage',
          name: 'Civic Signage & Maps',
          open: true,
          author: 'Lukas Meyer',
          desc: 'Wayfinding systems, railway timetables, and architectural diagrams built to last decades.'
        },
        {
          id: 'reading-notes',
          name: 'Marginalia & Quotes',
          open: false,
          author: 'Clara Vance',
          desc: 'Excerpts on craft, cybernetics, slow publishing, and vernacular architecture.'
        },
        {
          id: 'paper-systems',
          name: 'Paper & Print Systems',
          open: true,
          author: 'Otis Reid',
          desc: 'Index cards, ring binders, archival folders, and tactile filing methods.'
        }
      ];

      const BLOCKS = [
        {
          id: 'b1',
          channel: 'quiet-interfaces',
          kind: 'text',
          title: 'On Calm Tools',
          body: 'A good research tool feels like an empty wooden desk with good north light. It never asks you to celebrate a streak or chase a notification badge.',
          connections: 14,
          updated: '2h ago'
        },
        {
          id: 'b2',
          channel: 'civic-signage',
          kind: 'diagram',
          title: 'Basel Transit Grid Diagram',
          body: 'Orthogonal transfer diagram drawn on a 12-unit hairline grid with single-accent interchange markers.',
          connections: 9,
          updated: '5h ago',
          svg: `<svg viewBox="0 0 220 180" fill="none" stroke="#1A1A1A" stroke-width="1.2" aria-hidden="true">
            <line x1="20" y1="45" x2="200" y2="45"/>
            <line x1="20" y1="90" x2="200" y2="90"/>
            <line x1="20" y1="135" x2="200" y2="135"/>
            <line x1="75" y1="20" x2="75" y2="160"/>
            <line x1="145" y1="20" x2="145" y2="160"/>
            <circle cx="75" cy="90" r="7" fill="#FFFFFF" stroke="#17AC10" stroke-width="2.2"/>
            <circle cx="145" cy="45" r="7" fill="#FFFFFF" stroke="#1A1A1A" stroke-width="2"/>
            <circle cx="145" cy="135" r="5" fill="#1A1A1A"/>
            <text x="20" y="168" fill="#6D6D6D" stroke="none" font-family="monospace" font-size="10">FIG 02 — TRANSFER NODE</text>
          </svg>`
        },
        {
          id: 'b3',
          channel: 'reading-notes',
          kind: 'text',
          title: 'Christopher Alexander — Light on Two Sides',
          body: 'When they have a choice, people will always gravitate to those rooms which have light on two sides, and leave the rooms which are lit only from one side unused and empty.',
          connections: 27,
          updated: '1d ago'
        },
        {
          id: 'b4',
          channel: 'paper-systems',
          kind: 'diagram',
          title: 'A6 Zettelkasten Slip Geometry',
          body: 'Standard 105x148mm index card proportions with top-right alphanumeric address and bottom cross-reference footer.',
          connections: 18,
          updated: '1d ago',
          svg: `<svg viewBox="0 0 220 180" fill="none" stroke="#1A1A1A" stroke-width="1.1" aria-hidden="true">
            <rect x="26" y="24" width="168" height="122" fill="#FFFFFF"/>
            <line x1="26" y1="50" x2="194" y2="50" stroke="#D8D8D8"/>
            <line x1="26" y1="74" x2="194" y2="74" stroke="#D8D8D8"/>
            <line x1="26" y1="98" x2="194" y2="98" stroke="#D8D8D8"/>
            <line x1="26" y1="122" x2="194" y2="122" stroke="#D8D8D8"/>
            <text x="148" y="42" fill="#17AC10" stroke="none" font-family="monospace" font-size="10">14b/3a</text>
            <text x="36" y="42" fill="#1A1A1A" stroke="none" font-family="monospace" font-size="10">SLIP NOTE</text>
            <text x="36" y="164" fill="#6D6D6D" stroke="none" font-family="monospace" font-size="10">105 x 148 MM</text>
          </svg>`
        },
        {
          id: 'b5',
          channel: 'quiet-interfaces',
          kind: 'link',
          title: 'Low-Tech Magazine Solar Server Notes',
          body: 'https://solar.lowtechmagazine.com/about/the-solar-website — Static HTML, dithered graphics, and a live battery meter for the hosting server.',
          connections: 31,
          updated: '2d ago'
        },
        {
          id: 'b6',
          channel: 'civic-signage',
          kind: 'diagram',
          title: 'Proportion Study: Swiss Poster Grid',
          body: '4x4 modular field study with 1px structural dividers and asymmetric negative space.',
          connections: 11,
          updated: '3d ago',
          svg: `<svg viewBox="0 0 220 180" fill="none" stroke="#1A1A1A" stroke-width="1" aria-hidden="true">
            <rect x="30" y="16" width="160" height="148" fill="#FFFFFF"/>
            <line x1="70" y1="16" x2="70" y2="164" stroke="#D8D8D8"/>
            <line x1="110" y1="16" x2="110" y2="164" stroke="#D8D8D8"/>
            <line x1="150" y1="16" x2="150" y2="164" stroke="#D8D8D8"/>
            <line x1="30" y1="53" x2="190" y2="53" stroke="#D8D8D8"/>
            <line x1="30" y1="90" x2="190" y2="90" stroke="#D8D8D8"/>
            <line x1="30" y1="127" x2="190" y2="127" stroke="#D8D8D8"/>
            <rect x="70" y="53" width="80" height="37" fill="#1A1A1A"/>
            <rect x="110" y="90" width="40" height="37" fill="#17AC10"/>
          </svg>`
        },
        {
          id: 'b7',
          channel: 'reading-notes',
          kind: 'text',
          title: 'Ursula K. Le Guin — Carrier Bag Theory',
          body: 'Before the tool that forces energy outward, we made the tool that brings energy home: a leaf, a gourd, a net, a bag, a sling, a folder.',
          connections: 42,
          updated: '4d ago'
        },
        {
          id: 'b8',
          channel: 'paper-systems',
          kind: 'link',
          title: 'ISO 216 Paper Ratio Reference',
          body: 'https://clagnut.com/blog/2362 — Why the square root of 2 allows any sheet to fold in half while preserving identical aspect ratio.',
          connections: 8,
          updated: '5d ago'
        }
      ];

      let activeChannel = 'ALL';
      let query = '';

      const channelStrip = document.getElementById('channelStrip');
      const blocksGrid = document.getElementById('blocksGrid');
      const emptyMsg = document.getElementById('emptyMsg');
      const totalStats = document.getElementById('totalStats');
      const activeChannelTitle = document.getElementById('activeChannelTitle');
      const activeChannelDesc = document.getElementById('activeChannelDesc');
      const searchInput = document.getElementById('searchInput');

      const composerModal = document.getElementById('composerModal');
      const blockChannelSelect = document.getElementById('blockChannel');
      const composerForm = document.getElementById('composerForm');
      const readerModal = document.getElementById('readerModal');
      const readerTitle = document.getElementById('readerTitle');
      const readerMeta = document.getElementById('readerMeta');
      const readerContent = document.getElementById('readerContent');

      function populateChannelSelect() {
        blockChannelSelect.innerHTML = CHANNELS.map(c => `<option value="${c.id}">${c.name}</option>`).join('');
      }

      function renderChannelStrip() {
        const allBtn = `
          <button type="button" class="chan-pill ${activeChannel === 'ALL' ? 'active' : ''}" data-chan="ALL" role="tab" aria-selected="${activeChannel === 'ALL'}">
            <span>All Channels</span>
            <span class="pill-count">${BLOCKS.length}</span>
          </button>
        `;
        const pills = CHANNELS.map(ch => {
          const count = BLOCKS.filter(b => b.channel === ch.id).length;
          const isAct = activeChannel === ch.id;
          return `
            <button type="button" class="chan-pill ${isAct ? 'active' : ''}" data-chan="${ch.id}" role="tab" aria-selected="${isAct}">
              <span class="status-dot ${ch.open ? '' : 'closed'}" aria-hidden="true"></span>
              <span>${ch.name}</span>
              <span class="pill-count">${count}</span>
            </button>
          `;
        }).join('');
        channelStrip.innerHTML = allBtn + pills;
      }

      function renderBlocks() {
        const q = query.trim().toLowerCase();
        const filtered = BLOCKS.filter(b => {
          const chOk = activeChannel === 'ALL' || b.channel === activeChannel;
          const chObj = CHANNELS.find(c => c.id === b.channel);
          const hay = `${b.title} ${b.body} ${b.kind} ${chObj ? chObj.name : ''}`.toLowerCase();
          return chOk && (!q || hay.includes(q));
        });

        if (activeChannel === 'ALL') {
          activeChannelTitle.textContent = 'All Research Channels';
          activeChannelDesc.textContent = 'A calm, ad-free index of connected ideas, architectural sketches, reading excerpts, and slow-web references.';
        } else {
          const ch = CHANNELS.find(c => c.id === activeChannel);
          activeChannelTitle.textContent = ch.name;
          activeChannelDesc.textContent = `${ch.desc} Curated by ${ch.author}.`;
        }

        totalStats.textContent = `${CHANNELS.length} channels \u2022 ${filtered.length} ${filtered.length === 1 ? 'block' : 'blocks'}`;

        if (filtered.length === 0) {
          blocksGrid.innerHTML = '';
          emptyMsg.hidden = false;
          return;
        }
        emptyMsg.hidden = true;

        blocksGrid.innerHTML = filtered.map(b => {
          const ch = CHANNELS.find(c => c.id === b.channel);
          let inner = '';
          if (b.kind === 'diagram' && b.svg) {
            inner = `<div class="block-svg-wrap">${b.svg}</div>`;
          } else if (b.kind === 'link') {
            inner = `
              <p class="block-quote">${b.body}</p>
              <span class="block-link-url">LINK &nearr;</span>
            `;
          } else {
            inner = `
              <p class="block-quote">${b.body}</p>
              <span class="meta-mono">TEXT BLOCK</span>
            `;
          }

          return `
            <article class="block-card" data-read="${b.id}" tabindex="0" role="button" aria-label="Open block: ${b.title}">
              <div class="block-frame">${inner}</div>
              <div class="block-caption">
                <span class="block-title">${b.title}</span>
                <div class="block-meta">
                  <span>${ch ? ch.name : b.channel}</span>
                  <span class="conn-badge">${b.connections} conn</span>
                </div>
              </div>
            </article>
          `;
        }).join('');
      }

      function openReader(id) {
        const b = BLOCKS.find(item => item.id === id);
        if (!b) return;
        const ch = CHANNELS.find(c => c.id === b.channel);
        readerTitle.textContent = b.title;
        readerMeta.textContent = `CHANNEL: ${ch ? ch.name : b.channel}  |  TYPE: ${b.kind.toUpperCase()}  |  ${b.connections} CONNECTIONS  |  ${b.updated}`;
        if (b.kind === 'diagram' && b.svg) {
          readerContent.innerHTML = `${b.svg}<p style="margin:0.85rem 0 0;">${b.body}</p>`;
        } else {
          readerContent.textContent = b.body;
        }
        readerModal.classList.add('open');
      }

      channelStrip.addEventListener('click', e => {
        const btn = e.target.closest('[data-chan]');
        if (!btn) return;
        activeChannel = btn.dataset.chan;
        renderChannelStrip();
        renderBlocks();
      });

      searchInput.addEventListener('input', e => {
        query = e.target.value;
        renderBlocks();
      });

      blocksGrid.addEventListener('click', e => {
        const card = e.target.closest('[data-read]');
        if (card) openReader(card.dataset.read);
      });

      blocksGrid.addEventListener('keydown', e => {
        if (e.key === 'Enter' || e.key === ' ') {
          const card = e.target.closest('[data-read]');
          if (card) {
            e.preventDefault();
            openReader(card.dataset.read);
          }
        }
      });

      function openComposer() {
        if (activeChannel !== 'ALL') blockChannelSelect.value = activeChannel;
        composerModal.classList.add('open');
        document.getElementById('blockTitleInput').focus();
      }

      function closeComposer() {
        composerModal.classList.remove('open');
      }

      function closeReader() {
        readerModal.classList.remove('open');
      }

      document.getElementById('openComposerBtn').addEventListener('click', openComposer);
      document.getElementById('closeComposerBtn').addEventListener('click', closeComposer);
      document.getElementById('cancelComposerBtn').addEventListener('click', closeComposer);
      document.getElementById('closeReaderBtn').addEventListener('click', closeReader);
      document.getElementById('closeReaderFootBtn').addEventListener('click', closeReader);

      composerModal.addEventListener('click', e => { if (e.target === composerModal) closeComposer(); });
      readerModal.addEventListener('click', e => { if (e.target === readerModal) closeReader(); });

      composerForm.addEventListener('submit', e => {
        e.preventDefault();
        const channel = blockChannelSelect.value;
        const kind = document.getElementById('blockKind').value;
        const title = document.getElementById('blockTitleInput').value.trim();
        const body = document.getElementById('blockBodyInput').value.trim();
        if (!title || !body) return;

        BLOCKS.unshift({
          id: 'b-' + Date.now(),
          channel,
          kind,
          title,
          body,
          connections: 1,
          updated: 'just now'
        });
        composerForm.reset();
        closeComposer();
        renderChannelStrip();
        renderBlocks();
      });

      document.addEventListener('keydown', e => {
        if (e.key === 'Escape') {
          closeComposer();
          closeReader();
        }
      });

      populateChannelSelect();
      renderChannelStrip();
      renderBlocks();
    })();
  </script>
</body>
</html>
```
