{
  "id": 133,
  "slug": "dual-pane-markdown-editor",
  "name": "Live Dual-Pane Markdown Editor",
  "kind": "ui",
  "family": "Workspace & Editor",
  "sourceSite": {
    "name": "HackMD",
    "url": "https://hackmd.io/",
    "verifiedStatus": 200
  },
  "tagline": "Warm-paper split Markdown editor with live parsed preview, focus mode, reading metrics, and Edit/Preview tabs on mobile.",
  "whyUnique": "Pairs distraction-free monospace authoring with instant typographic preview, interactive checklists, and a Focus mode that dims chrome while transforming into clean full-width tabs on 390px screens.",
  "theme": "light",
  "mobileStrength": "native-first",
  "tags": [
    "markdown-editor",
    "split-pane",
    "live-preview",
    "writing-app",
    "focus-mode",
    "typography"
  ],
  "bestFor": [
    "Technical blogs and documentation editors",
    "Long-form writing and newsletter apps",
    "Git-backed wikis and README composers",
    "Knowledge management note editors"
  ],
  "palette": [
    {
      "role": "canvas",
      "hex": "#FAF9F6",
      "name": "Warm Alabaster"
    },
    {
      "role": "surface",
      "hex": "#FFFFFF",
      "name": "Sheet White"
    },
    {
      "role": "ink",
      "hex": "#1F1E1C",
      "name": "Typewriter Ink"
    },
    {
      "role": "accent",
      "hex": "#1D6FA5",
      "name": "Editorial Blue"
    },
    {
      "role": "muted",
      "hex": "#6E6A63",
      "name": "Stone Gray"
    }
  ],
  "typography": {
    "display": "Newsreader",
    "body": "Inter",
    "mono": "IBM Plex Mono",
    "googleFontsUrl": "https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Inter:wght@400;500;600&family=Newsreader:wght@600;700&display=swap",
    "scaleNotes": "15px/1.7 monospace authoring pane paired with 16px/1.75 formatted editorial preview and 12px mono status bar."
  },
  "layoutNotes": "50/50 split panes with a hairline vertical divider on desktop; segmented Edit / Preview tab switcher on mobile viewports.",
  "interactionNotes": "Real-time Markdown parser renders headings, bold, italic, inline/fenced code, blockquotes, lists, and checkboxes on every keystroke, plus formatting toolbar insertions and Focus mode.",
  "mobileNotes": "Replaces cramped dual columns with a full-width segmented Edit / Preview toggle and thumb-friendly formatting pills so writing stays comfortable on 390px screens.",
  "agentGuardrails": {
    "do": [
      "Switch split editor/preview panes to a segmented Edit / Preview tab control below 768px.",
      "Use a monospace font in the raw Markdown pane and editorial typography in the preview pane.",
      "Show live word count and estimated reading time in a subtle footer bar."
    ],
    "dont": [
      "Never render a 50/50 side-by-side editor and preview on a 390px phone.",
      "Avoid injecting unsanitized raw HTML from user Markdown without escaping."
    ]
  },
  "demoFile": "demos/dual-pane-markdown-editor.html",
  "thumbDesktop": "thumbs/dual-pane-markdown-editor-desktop.webp",
  "thumbMobile": "thumbs/dual-pane-markdown-editor-mobile.webp",
  "urls": {
    "page": "https://templates.michaelpitts.net/t/dual-pane-markdown-editor",
    "markdown": "https://templates.michaelpitts.net/t/dual-pane-markdown-editor.md",
    "api": "https://templates.michaelpitts.net/api/templates/dual-pane-markdown-editor",
    "demo": "https://templates.michaelpitts.net/demos/dual-pane-markdown-editor.html",
    "thumbDesktop": "https://templates.michaelpitts.net/thumbs/dual-pane-markdown-editor-desktop.webp",
    "thumbMobile": "https://templates.michaelpitts.net/thumbs/dual-pane-markdown-editor-mobile.webp"
  },
  "agentPrompt": "Design & build using template #133 \"Live Dual-Pane Markdown Editor\" (ui / Workspace & Editor, light theme).\nFull AI blueprint & standalone starter code: https://templates.michaelpitts.net/t/dual-pane-markdown-editor.md\nLive demo: https://templates.michaelpitts.net/demos/dual-pane-markdown-editor.html\nReal-world inspiration: HackMD (https://hackmd.io/)\n\nCore aesthetic: Pairs distraction-free monospace authoring with instant typographic preview, interactive checklists, and a Focus mode that dims chrome while transforming into clean full-width tabs on 390px screens.\nPalette: canvas: #FAF9F6 (Warm Alabaster), surface: #FFFFFF (Sheet White), ink: #1F1E1C (Typewriter Ink), accent: #1D6FA5 (Editorial Blue), muted: #6E6A63 (Stone Gray)\nTypography: Display=\"Newsreader\", Body=\"Inter\", Mono=\"IBM Plex Mono\"\nLayout: 50/50 split panes with a hairline vertical divider on desktop; segmented Edit / Preview tab switcher on mobile viewports.\nInteractions: Real-time Markdown parser renders headings, bold, italic, inline/fenced code, blockquotes, lists, and checkboxes on every keystroke, plus formatting toolbar insertions and Focus mode.\nMobile: Replaces cramped dual columns with a full-width segmented Edit / Preview toggle and thumb-friendly formatting pills so writing stays comfortable on 390px screens.\n\nGuardrails:\n- DO: Switch split editor/preview panes to a segmented Edit / Preview tab control below 768px.\n- DO: Use a monospace font in the raw Markdown pane and editorial typography in the preview pane.\n- DO: Show live word count and estimated reading time in a subtle footer bar.\n- DON'T: Never render a 50/50 side-by-side editor and preview on a 390px phone.\n- DON'T: Avoid injecting unsanitized raw HTML from user Markdown without escaping.",
  "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>Folio — Dual-Pane Markdown Editor</title>\n  <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n  <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n  <link href=\"https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,500;0,600;1,400&family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,400&family=Inter:wght@400;500;600&display=swap\" rel=\"stylesheet\">\n  <style>\n    :root {\n      --paper: #fbf9f5;\n      --paper-muted: #f3efe6;\n      --paper-elevated: #ffffff;\n      --ink: #1c1b18;\n      --ink-secondary: #5c574f;\n      --ink-faint: #8e887d;\n      --hairline: #e6e0d4;\n      --accent: #0066cc;\n      --accent-soft: rgba(0, 102, 204, 0.1);\n      --code-bg: #f1ece2;\n      --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;\n      --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;\n      --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;\n    }\n\n    body.dark-paper {\n      --paper: #171614;\n      --paper-muted: #201e1b;\n      --paper-elevated: #25231f;\n      --ink: #ece8df;\n      --ink-secondary: #a7a093;\n      --ink-faint: #736d63;\n      --hairline: #2f2c27;\n      --accent: #4da3ff;\n      --accent-soft: rgba(77, 163, 255, 0.15);\n      --code-bg: #26231e;\n    }\n\n    * {\n      box-sizing: border-box;\n      margin: 0;\n      padding: 0;\n    }\n\n    html, body {\n      height: 100%;\n      background: var(--paper);\n      color: var(--ink);\n      font-family: var(--font-sans);\n      -webkit-font-smoothing: antialiased;\n      overflow-x: hidden;\n    }\n\n    .app {\n      display: flex;\n      flex-direction: column;\n      height: 100dvh;\n      max-width: 100vw;\n      overflow: hidden;\n    }\n\n    /* Top Chrome */\n    .topbar {\n      display: flex;\n      align-items: center;\n      justify-content: space-between;\n      gap: 12px;\n      padding: 0 20px;\n      height: 54px;\n      border-bottom: 1px solid var(--hairline);\n      background: var(--paper);\n      flex-shrink: 0;\n      transition: opacity 0.25s ease;\n    }\n\n    body.focus-mode .topbar {\n      opacity: 0.35;\n    }\n    body.focus-mode .topbar:hover,\n    body.focus-mode .topbar:focus-within {\n      opacity: 1;\n    }\n\n    .doc-meta {\n      display: flex;\n      align-items: center;\n      gap: 10px;\n      min-width: 0;\n    }\n\n    .brand-mark {\n      width: 24px;\n      height: 24px;\n      border-radius: 5px;\n      background: var(--ink);\n      color: var(--paper);\n      display: grid;\n      place-items: center;\n      font-family: var(--font-mono);\n      font-size: 12px;\n      font-weight: 600;\n      flex-shrink: 0;\n    }\n\n    .doc-title-input {\n      background: transparent;\n      border: none;\n      color: var(--ink);\n      font-family: var(--font-sans);\n      font-size: 14px;\n      font-weight: 500;\n      width: 210px;\n      max-width: 100%;\n      padding: 4px 6px;\n      border-radius: 4px;\n      text-overflow: ellipsis;\n    }\n    .doc-title-input:focus {\n      outline: none;\n      background: var(--paper-muted);\n    }\n\n    .saved-dot {\n      font-size: 12px;\n      color: var(--ink-faint);\n      white-space: nowrap;\n    }\n\n    .toolbar-actions {\n      display: flex;\n      align-items: center;\n      gap: 6px;\n    }\n\n    .btn {\n      appearance: none;\n      border: 1px solid transparent;\n      background: transparent;\n      color: var(--ink-secondary);\n      font-family: var(--font-sans);\n      font-size: 13px;\n      font-weight: 500;\n      padding: 0 10px;\n      height: 36px;\n      border-radius: 6px;\n      cursor: pointer;\n      display: inline-flex;\n      align-items: center;\n      gap: 6px;\n      transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;\n      white-space: nowrap;\n    }\n\n    .btn:hover {\n      background: var(--paper-muted);\n      color: var(--ink);\n    }\n\n    .btn.active {\n      background: var(--accent-soft);\n      color: var(--accent);\n      border-color: rgba(0, 102, 204, 0.22);\n    }\n\n    .btn-primary {\n      background: var(--ink);\n      color: var(--paper);\n    }\n    .btn-primary:hover {\n      background: var(--ink-secondary);\n      color: var(--paper);\n    }\n\n    /* Formatting Ribbon */\n    .format-bar {\n      display: flex;\n      align-items: center;\n      justify-content: space-between;\n      gap: 8px;\n      padding: 6px 20px;\n      border-bottom: 1px solid var(--hairline);\n      background: var(--paper-muted);\n      flex-shrink: 0;\n      overflow-x: auto;\n      scrollbar-width: none;\n      transition: opacity 0.25s ease;\n    }\n    .format-bar::-webkit-scrollbar { display: none; }\n\n    body.focus-mode .format-bar {\n      opacity: 0.25;\n    }\n    body.focus-mode .format-bar:hover {\n      opacity: 1;\n    }\n\n    .format-group {\n      display: flex;\n      align-items: center;\n      gap: 2px;\n    }\n\n    .fmt-btn {\n      appearance: none;\n      border: none;\n      background: transparent;\n      color: var(--ink-secondary);\n      font-family: var(--font-mono);\n      font-size: 12px;\n      font-weight: 500;\n      min-width: 34px;\n      height: 34px;\n      padding: 0 8px;\n      border-radius: 5px;\n      cursor: pointer;\n      display: inline-flex;\n      align-items: center;\n      justify-content: center;\n      transition: background 0.12s, color 0.12s;\n    }\n    .fmt-btn:hover {\n      background: var(--paper-elevated);\n      color: var(--ink);\n    }\n\n    .divider-v {\n      width: 1px;\n      height: 18px;\n      background: var(--hairline);\n      margin: 0 6px;\n      flex-shrink: 0;\n    }\n\n    /* Mobile Segmented Switcher */\n    .mobile-tabs {\n      display: none;\n      padding: 8px 16px;\n      background: var(--paper);\n      border-bottom: 1px solid var(--hairline);\n      flex-shrink: 0;\n    }\n\n    .segmented {\n      display: grid;\n      grid-template-columns: 1fr 1fr;\n      background: var(--paper-muted);\n      padding: 3px;\n      border-radius: 9px;\n      gap: 4px;\n    }\n\n    .seg-btn {\n      appearance: none;\n      border: none;\n      background: transparent;\n      color: var(--ink-secondary);\n      font-family: var(--font-sans);\n      font-size: 14px;\n      font-weight: 500;\n      min-height: 44px;\n      border-radius: 7px;\n      cursor: pointer;\n      transition: background 0.15s, color 0.15s, box-shadow 0.15s;\n    }\n\n    .seg-btn.active {\n      background: var(--paper-elevated);\n      color: var(--ink);\n      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);\n    }\n\n    /* Workspace Split */\n    .workspace {\n      flex: 1;\n      display: grid;\n      grid-template-columns: 1fr 1px 1fr;\n      min-height: 0;\n      overflow: hidden;\n    }\n\n    .pane {\n      height: 100%;\n      overflow-y: auto;\n      min-width: 0;\n    }\n\n    .pane-divider {\n      background: var(--hairline);\n      width: 1px;\n    }\n\n    .editor-pane {\n      background: var(--paper);\n      display: flex;\n      flex-direction: column;\n    }\n\n    .editor-inner {\n      flex: 1;\n      width: 100%;\n      max-width: 68ch;\n      margin: 0 auto;\n      padding: 36px 32px 120px;\n      display: flex;\n      flex-direction: column;\n    }\n\n    .editor-textarea {\n      flex: 1;\n      width: 100%;\n      min-height: 100%;\n      border: none;\n      outline: none;\n      resize: none;\n      background: transparent;\n      color: var(--ink);\n      font-family: var(--font-mono);\n      font-size: 14.5px;\n      line-height: 1.85;\n      caret-color: var(--accent);\n      tab-size: 2;\n    }\n\n    body.focus-mode .editor-textarea {\n      color: var(--ink);\n    }\n\n    /* Preview Pane */\n    .preview-pane {\n      background: var(--paper-elevated);\n      scroll-behavior: smooth;\n    }\n\n    .preview-inner {\n      max-width: 66ch;\n      margin: 0 auto;\n      padding: 40px 40px 120px;\n      font-family: var(--font-serif);\n      font-size: 18px;\n      line-height: 1.72;\n      color: var(--ink);\n    }\n\n    .preview-inner .md-block {\n      transition: opacity 0.25s ease;\n    }\n\n    body.focus-mode .preview-inner .md-block {\n      opacity: 0.24;\n    }\n\n    body.focus-mode .preview-inner .md-block.is-focused {\n      opacity: 1;\n    }\n\n    .preview-inner h1 {\n      font-size: 2.05em;\n      line-height: 1.18;\n      font-weight: 600;\n      letter-spacing: -0.02em;\n      margin: 0 0 0.65em;\n    }\n\n    .preview-inner h2 {\n      font-size: 1.42em;\n      line-height: 1.28;\n      font-weight: 600;\n      letter-spacing: -0.015em;\n      margin: 1.6em 0 0.5em;\n      padding-bottom: 0.25em;\n      border-bottom: 1px solid var(--hairline);\n    }\n\n    .preview-inner h3 {\n      font-size: 1.15em;\n      font-weight: 600;\n      margin: 1.3em 0 0.4em;\n    }\n\n    .preview-inner p {\n      margin: 0 0 1.05em;\n    }\n\n    .preview-inner blockquote {\n      margin: 1.25em 0;\n      padding: 4px 0 4px 18px;\n      border-left: 3px solid var(--accent);\n      color: var(--ink-secondary);\n      font-style: italic;\n    }\n\n    .preview-inner ul, .preview-inner ol {\n      margin: 0 0 1.1em 1.35em;\n    }\n\n    .preview-inner li {\n      margin-bottom: 0.35em;\n    }\n\n    .preview-inner .task-list {\n      list-style: none;\n      margin-left: 0;\n    }\n\n    .preview-inner .task-item {\n      display: flex;\n      align-items: baseline;\n      gap: 10px;\n      margin-bottom: 0.4em;\n    }\n\n    .preview-inner .task-item input[type=\"checkbox\"] {\n      accent-color: var(--accent);\n      width: 15px;\n      height: 15px;\n      cursor: pointer;\n      transform: translateY(2px);\n    }\n\n    .preview-inner .task-item.checked span {\n      text-decoration: line-through;\n      color: var(--ink-faint);\n    }\n\n    .preview-inner code {\n      font-family: var(--font-mono);\n      font-size: 0.82em;\n      background: var(--code-bg);\n      padding: 2px 6px;\n      border-radius: 4px;\n    }\n\n    .preview-inner pre {\n      background: var(--code-bg);\n      border: 1px solid var(--hairline);\n      border-radius: 8px;\n      padding: 14px 16px;\n      margin: 1.2em 0;\n      overflow-x: auto;\n    }\n\n    .preview-inner pre code {\n      background: transparent;\n      padding: 0;\n      font-size: 13px;\n      line-height: 1.6;\n      display: block;\n    }\n\n    .preview-inner hr {\n      border: none;\n      border-top: 1px solid var(--hairline);\n      margin: 1.8em 0;\n    }\n\n    .preview-inner a {\n      color: var(--accent);\n      text-underline-offset: 3px;\n    }\n\n    .preview-inner table {\n      width: 100%;\n      border-collapse: collapse;\n      margin: 1.2em 0;\n      font-family: var(--font-sans);\n      font-size: 14px;\n    }\n\n    .preview-inner th, .preview-inner td {\n      border-bottom: 1px solid var(--hairline);\n      padding: 8px 10px;\n      text-align: left;\n    }\n\n    .preview-inner th {\n      font-weight: 600;\n      color: var(--ink-secondary);\n      font-size: 12px;\n      text-transform: uppercase;\n      letter-spacing: 0.04em;\n    }\n\n    /* Status Footer */\n    .statusbar {\n      display: flex;\n      align-items: center;\n      justify-content: space-between;\n      gap: 12px;\n      padding: 0 20px;\n      height: 36px;\n      border-top: 1px solid var(--hairline);\n      background: var(--paper);\n      font-family: var(--font-mono);\n      font-size: 11.5px;\n      color: var(--ink-faint);\n      flex-shrink: 0;\n    }\n\n    .stats-group {\n      display: flex;\n      align-items: center;\n      gap: 16px;\n      flex-wrap: nowrap;\n      overflow: hidden;\n    }\n\n    .stat-pill strong {\n      color: var(--ink-secondary);\n      font-weight: 600;\n    }\n\n    .toast {\n      position: fixed;\n      bottom: 48px;\n      right: 20px;\n      background: var(--ink);\n      color: var(--paper);\n      font-size: 13px;\n      font-weight: 500;\n      padding: 9px 14px;\n      border-radius: 8px;\n      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);\n      opacity: 0;\n      transform: translateY(8px);\n      pointer-events: none;\n      transition: opacity 0.2s, transform 0.2s;\n      z-index: 50;\n    }\n    .toast.show {\n      opacity: 1;\n      transform: translateY(0);\n    }\n\n    /* Responsive Mobile Transformation */\n    @media (max-width: 820px) {\n      .topbar {\n        padding: 0 12px;\n        height: 56px;\n      }\n\n      .doc-title-input {\n        width: 135px;\n        font-size: 14px;\n      }\n\n      .saved-dot, .hide-mobile {\n        display: none;\n      }\n\n      .btn {\n        min-height: 44px;\n        padding: 0 10px;\n      }\n\n      .format-bar {\n        padding: 4px 12px;\n      }\n\n      .fmt-btn {\n        min-width: 44px;\n        min-height: 44px;\n      }\n\n      .mobile-tabs {\n        display: block;\n      }\n\n      .workspace {\n        grid-template-columns: 1fr;\n      }\n\n      .pane-divider {\n        display: none;\n      }\n\n      .workspace[data-mobile-tab=\"edit\"] .preview-pane {\n        display: none;\n      }\n\n      .workspace[data-mobile-tab=\"preview\"] .editor-pane {\n        display: none;\n      }\n\n      .editor-inner {\n        padding: 20px 16px 80px;\n      }\n\n      .preview-inner {\n        padding: 22px 18px 80px;\n        font-size: 16.5px;\n      }\n\n      .statusbar {\n        padding: 0 14px;\n        font-size: 11px;\n      }\n    }\n  </style>\n</head>\n<body>\n  <div class=\"app\">\n    <header class=\"topbar\">\n      <div class=\"doc-meta\">\n        <div class=\"brand-mark\" aria-hidden=\"true\">¶</div>\n        <input id=\"docTitle\" class=\"doc-title-input\" type=\"text\" value=\"quiet-software-notes.md\" aria-label=\"Document filename\">\n        <span id=\"saveStatus\" class=\"saved-dot\">Saved locally</span>\n      </div>\n      <div class=\"toolbar-actions\">\n        <button id=\"focusBtn\" class=\"btn\" type=\"button\" title=\"Toggle Focus Mode (Alt+F)\">\n          <svg width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><circle cx=\"12\" cy=\"12\" r=\"3\"/><path d=\"M3 12h3m12 0h3M12 3v3m0 12v3\"/></svg>\n          <span>Focus</span>\n        </button>\n        <button id=\"themeBtn\" class=\"btn\" type=\"button\" aria-label=\"Toggle dark paper theme\">\n          <svg width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z\"/></svg>\n          <span class=\"hide-mobile\">Ink</span>\n        </button>\n        <button id=\"copyHtmlBtn\" class=\"btn btn-primary\" type=\"button\">Copy HTML</button>\n      </div>\n    </header>\n\n    <div class=\"format-bar\" role=\"toolbar\" aria-label=\"Markdown formatting\">\n      <div class=\"format-group\">\n        <button class=\"fmt-btn\" type=\"button\" data-action=\"h2\" title=\"Heading 2\">H2</button>\n        <button class=\"fmt-btn\" type=\"button\" data-action=\"bold\" title=\"Bold\"><strong>B</strong></button>\n        <button class=\"fmt-btn\" type=\"button\" data-action=\"italic\" title=\"Italic\"><em>I</em></button>\n        <button class=\"fmt-btn\" type=\"button\" data-action=\"code\" title=\"Inline Code\">&lt;/&gt;</button>\n        <div class=\"divider-v\"></div>\n        <button class=\"fmt-btn\" type=\"button\" data-action=\"quote\" title=\"Blockquote\">“”</button>\n        <button class=\"fmt-btn\" type=\"button\" data-action=\"task\" title=\"Task item\">☑</button>\n        <button class=\"fmt-btn\" type=\"button\" data-action=\"hr\" title=\"Divider\">―</button>\n      </div>\n      <span class=\"hide-mobile\" style=\"font-size:12px;color:var(--ink-faint);font-family:var(--font-mono);\">\n        Markdown · Live Sync\n      </span>\n    </div>\n\n    <div class=\"mobile-tabs\" role=\"tablist\" aria-label=\"Editor view\">\n      <div class=\"segmented\">\n        <button id=\"tabEdit\" class=\"seg-btn active\" role=\"tab\" aria-selected=\"true\" type=\"button\">Edit</button>\n        <button id=\"tabPreview\" class=\"seg-btn\" role=\"tab\" aria-selected=\"false\" type=\"button\">Preview</button>\n      </div>\n    </div>\n\n    <main id=\"workspace\" class=\"workspace\" data-mobile-tab=\"edit\">\n      <section class=\"pane editor-pane\" aria-label=\"Markdown editor\">\n        <div class=\"editor-inner\">\n          <textarea id=\"editor\" class=\"editor-textarea\" spellcheck=\"true\" aria-label=\"Markdown source\"></textarea>\n        </div>\n      </section>\n      <div class=\"pane-divider\" aria-hidden=\"true\"></div>\n      <section id=\"previewPane\" class=\"pane preview-pane\" aria-label=\"Rendered preview\">\n        <article id=\"preview\" class=\"preview-inner\"></article>\n      </section>\n    </main>\n\n    <footer class=\"statusbar\">\n      <div class=\"stats-group\">\n        <span class=\"stat-pill\"><strong id=\"wordCount\">0</strong> words</span>\n        <span class=\"stat-pill\"><strong id=\"charCount\">0</strong> chars</span>\n        <span class=\"stat-pill hide-mobile\"><strong id=\"paraCount\">0</strong> paragraphs</span>\n        <span class=\"stat-pill\"><strong id=\"readTime\">1 min</strong> read</span>\n      </div>\n      <span id=\"cursorPos\">Ln 1, Col 1</span>\n    </footer>\n  </div>\n\n  <div id=\"toast\" class=\"toast\" role=\"status\" aria-live=\"polite\"></div>\n\n  <script>\n    const INITIAL_MD = `# Field Notes on Quiet Software\n\nWriting tools fail most often by asking for attention before the writer has finished a sentence. When chrome recedes, structure becomes legible again.\n\n> Good typography is invisible until it breaks—then it is all the reader can see.\n\n## Principles for Calm Editing\n\nA dual-pane draft works best when **raw syntax** stays crisp in monospace on the left while the rendered cadence breathes in serif on the right.\n\n- Keep line measure between \\`60\\` and \\`72\\` characters\n- Reserve high-contrast accents strictly for cursor and links\n- Dim surrounding paragraphs in *Focus Mode* when drafting\n\n## Revision Checklist\n\n- [x] Verify heading rhythm and vertical spacing\n- [x] Add inline code and table support to parser\n- [ ] Trim opening paragraph by fifteen words\n- [ ] Export clean HTML for the weekend essay\n\n## Reading Cadence Benchmarks\n\n| Mode | Measure | Font Family | Purpose |\n| :--- | :--- | :--- | :--- |\n| Draft | 66 ch | IBM Plex Mono | Structural clarity |\n| Proof | 64 ch | Newsreader | Typographic rhythm |\n\n\\`\\`\\`js\nfunction estimateReadingTime(text) {\n  const words = text.trim().split(/\\\\s+/).filter(Boolean).length;\n  return Math.max(1, Math.ceil(words / 225));\n}\n\\`\\`\\`\n\n---\n\nTry editing any paragraph on the left, toggling **Focus** mode to spotlight the active block, or clicking a checkbox in the preview.`;\n\n    const editor = document.getElementById('editor');\n    const preview = document.getElementById('preview');\n    const workspace = document.getElementById('workspace');\n    const focusBtn = document.getElementById('focusBtn');\n    const themeBtn = document.getElementById('themeBtn');\n    const copyHtmlBtn = document.getElementById('copyHtmlBtn');\n    const tabEdit = document.getElementById('tabEdit');\n    const tabPreview = document.getElementById('tabPreview');\n    const saveStatus = document.getElementById('saveStatus');\n    const toast = document.getElementById('toast');\n\n    let toastTimer = null;\n    function showToast(msg) {\n      toast.textContent = msg;\n      toast.classList.add('show');\n      clearTimeout(toastTimer);\n      toastTimer = setTimeout(() => toast.classList.remove('show'), 2200);\n    }\n\n    function escapeHtml(str) {\n      return str\n        .replace(/&/g, '&amp;')\n        .replace(/</g, '&lt;')\n        .replace(/>/g, '&gt;')\n        .replace(/\"/g, '&quot;');\n    }\n\n    function parseInline(text) {\n      let s = escapeHtml(text);\n      s = s.replace(/`([^`]+)`/g, '<code>$1</code>');\n      s = s.replace(/\\*\\*([^*]+)\\*\\*/g, '<strong>$1</strong>');\n      s = s.replace(/\\*([^*]+)\\*/g, '<em>$1</em>');\n      s = s.replace(/\\[([^\\]]+)\\]\\((https?:\\/\\/[^\\s)]+)\\)/g, '<a href=\"$2\" target=\"_blank\" rel=\"noopener\">$1</a>');\n      return s;\n    }\n\n    function parseMarkdownBlocks(md) {\n      const lines = md.replace(/\\r\\n/g, '\\n').split('\\n');\n      const blocks = [];\n      let i = 0;\n\n      while (i < lines.length) {\n        const line = lines[i];\n        if (!line.trim()) {\n          i++;\n          continue;\n        }\n\n        const startLine = i;\n\n        // Fenced code block\n        if (/^```/.test(line.trim())) {\n          const lang = line.trim().slice(3).trim();\n          const codeLines = [];\n          i++;\n          while (i < lines.length && !/^```/.test(lines[i].trim())) {\n            codeLines.push(lines[i]);\n            i++;\n          }\n          const endLine = i;\n          i++;\n          blocks.push({\n            startLine,\n            endLine,\n            html: `<pre><code data-lang=\"${escapeHtml(lang)}\">${escapeHtml(codeLines.join('\\n'))}</code></pre>`\n          });\n          continue;\n        }\n\n        // Heading\n        const hMatch = line.match(/^(#{1,3})\\s+(.*)$/);\n        if (hMatch) {\n          const level = hMatch[1].length;\n          blocks.push({\n            startLine,\n            endLine: i,\n            html: `<h${level}>${parseInline(hMatch[2])}</h${level}>`\n          });\n          i++;\n          continue;\n        }\n\n        // Horizontal rule\n        if (/^(-{3,}|\\*{3,})$/.test(line.trim())) {\n          blocks.push({ startLine, endLine: i, html: '<hr>' });\n          i++;\n          continue;\n        }\n\n        // Blockquote\n        if (/^>\\s?/.test(line)) {\n          const qLines = [];\n          while (i < lines.length && /^>\\s?/.test(lines[i])) {\n            qLines.push(lines[i].replace(/^>\\s?/, ''));\n            i++;\n          }\n          blocks.push({\n            startLine,\n            endLine: i - 1,\n            html: `<blockquote><p>${parseInline(qLines.join(' '))}</p></blockquote>`\n          });\n          continue;\n        }\n\n        // Table\n        if (line.includes('|') && i + 1 < lines.length && /^\\s*\\|?[\\s:-]+\\|[\\s|:-]+$/.test(lines[i + 1])) {\n          const headerCells = line.trim().replace(/^\\||\\|$/g, '').split('|').map(c => c.trim());\n          i += 2;\n          const rows = [];\n          while (i < lines.length && lines[i].includes('|') && lines[i].trim()) {\n            rows.push(lines[i].trim().replace(/^\\||\\|$/g, '').split('|').map(c => c.trim()));\n            i++;\n          }\n          const thead = `<thead><tr>${headerCells.map(c => `<th>${parseInline(c)}</th>`).join('')}</tr></thead>`;\n          const tbody = `<tbody>${rows.map(r => `<tr>${r.map(c => `<td>${parseInline(c)}</td>`).join('')}</tr>`).join('')}</tbody>`;\n          blocks.push({\n            startLine,\n            endLine: i - 1,\n            html: `<table>${thead}${tbody}</table>`\n          });\n          continue;\n        }\n\n        // Task list\n        if (/^\\s*-\\s+\\[( |x|X)\\]\\s+/.test(line)) {\n          const items = [];\n          while (i < lines.length && /^\\s*-\\s+\\[( |x|X)\\]\\s+/.test(lines[i])) {\n            const m = lines[i].match(/^\\s*-\\s+\\[( |x|X)\\]\\s+(.*)$/);\n            const checked = m[1].toLowerCase() === 'x';\n            items.push(`<li class=\"task-item ${checked ? 'checked' : ''}\"><input type=\"checkbox\" data-line=\"${i}\" ${checked ? 'checked' : ''}><span>${parseInline(m[2])}</span></li>`);\n            i++;\n          }\n          blocks.push({\n            startLine,\n            endLine: i - 1,\n            html: `<ul class=\"task-list\">${items.join('')}</ul>`\n          });\n          continue;\n        }\n\n        // Unordered list\n        if (/^\\s*[-*]\\s+/.test(line)) {\n          const items = [];\n          while (i < lines.length && /^\\s*[-*]\\s+/.test(lines[i])) {\n            items.push(`<li>${parseInline(lines[i].replace(/^\\s*[-*]\\s+/, ''))}</li>`);\n            i++;\n          }\n          blocks.push({\n            startLine,\n            endLine: i - 1,\n            html: `<ul>${items.join('')}</ul>`\n          });\n          continue;\n        }\n\n        // Paragraph\n        const pLines = [];\n        while (\n          i < lines.length &&\n          lines[i].trim() &&\n          !/^(#{1,3}\\s|```|>\\s?|[-*]\\s+|-{3,}$)/.test(lines[i])\n        ) {\n          pLines.push(lines[i]);\n          i++;\n        }\n        blocks.push({\n          startLine,\n          endLine: i - 1,\n          html: `<p>${parseInline(pLines.join(' '))}</p>`\n        });\n      }\n\n      return blocks;\n    }\n\n    function getActiveLineIndex() {\n      const pos = editor.selectionStart || 0;\n      return editor.value.slice(0, pos).split('\\n').length - 1;\n    }\n\n    function updateCursorAndFocus() {\n      const pos = editor.selectionStart || 0;\n      const before = editor.value.slice(0, pos).split('\\n');\n      const ln = before.length;\n      const col = before[before.length - 1].length + 1;\n      document.getElementById('cursorPos').textContent = `Ln ${ln}, Col ${col}`;\n\n      const activeLine = ln - 1;\n      const blockEls = preview.querySelectorAll('.md-block');\n      blockEls.forEach(el => {\n        const start = Number(el.dataset.start);\n        const end = Number(el.dataset.end);\n        el.classList.toggle('is-focused', activeLine >= start && activeLine <= end);\n      });\n    }\n\n    function render() {\n      const text = editor.value;\n      const blocks = parseMarkdownBlocks(text);\n      preview.innerHTML = blocks\n        .map(b => `<div class=\"md-block\" data-start=\"${b.startLine}\" data-end=\"${b.endLine}\">${b.html}</div>`)\n        .join('');\n\n      const words = text.trim() ? text.trim().split(/\\s+/).filter(Boolean).length : 0;\n      const chars = text.length;\n      const paras = text.split(/\\n\\s*\\n/).filter(p => p.trim()).length;\n      const mins = Math.max(1, Math.ceil(words / 225));\n\n      document.getElementById('wordCount').textContent = words.toLocaleString();\n      document.getElementById('charCount').textContent = chars.toLocaleString();\n      document.getElementById('paraCount').textContent = paras;\n      document.getElementById('readTime').textContent = `${mins} min`;\n\n      updateCursorAndFocus();\n    }\n\n    // Interactive checkboxes in preview sync back to markdown source\n    preview.addEventListener('change', (e) => {\n      if (e.target.matches('input[type=\"checkbox\"][data-line]')) {\n        const lineIdx = Number(e.target.dataset.line);\n        const lines = editor.value.split('\\n');\n        if (lines[lineIdx] !== undefined) {\n          lines[lineIdx] = e.target.checked\n            ? lines[lineIdx].replace(/\\[ \\]/, '[x]')\n            : lines[lineIdx].replace(/\\[[xX]\\]/, '[ ]');\n          editor.value = lines.join('\\n');\n          render();\n          showToast(e.target.checked ? 'Marked task complete' : 'Reopened task');\n        }\n      }\n    });\n\n    // Formatting toolbar actions\n    document.querySelectorAll('.fmt-btn[data-action]').forEach(btn => {\n      btn.addEventListener('click', () => {\n        const action = btn.dataset.action;\n        const start = editor.selectionStart;\n        const end = editor.selectionEnd;\n        const val = editor.value;\n        const sel = val.slice(start, end);\n\n        let replacement = sel;\n        let cursorOffset = 0;\n\n        if (action === 'bold') {\n          replacement = `**${sel || 'bold text'}**`;\n          cursorOffset = sel ? replacement.length : 2;\n        } else if (action === 'italic') {\n          replacement = `*${sel || 'italic text'}*`;\n          cursorOffset = sel ? replacement.length : 1;\n        } else if (action === 'code') {\n          replacement = `\\`${sel || 'code'}\\``;\n          cursorOffset = sel ? replacement.length : 1;\n        } else if (action === 'h2') {\n          replacement = `\\n## ${sel || 'Section Heading'}\\n`;\n          cursorOffset = replacement.length - 1;\n        } else if (action === 'quote') {\n          replacement = `\\n> ${sel || 'Pull quote or reflection.'}\\n`;\n          cursorOffset = replacement.length - 1;\n        } else if (action === 'task') {\n          replacement = `\\n- [ ] ${sel || 'Follow-up item'}`;\n          cursorOffset = replacement.length;\n        } else if (action === 'hr') {\n          replacement = `\\n\\n---\\n\\n`;\n          cursorOffset = replacement.length;\n        }\n\n        editor.value = val.slice(0, start) + replacement + val.slice(end);\n        editor.focus();\n        editor.setSelectionRange(start + cursorOffset, start + cursorOffset);\n        render();\n      });\n    });\n\n    // Focus mode toggle\n    function toggleFocus() {\n      const on = document.body.classList.toggle('focus-mode');\n      focusBtn.classList.toggle('active', on);\n      updateCursorAndFocus();\n      showToast(on ? 'Focus Mode on — active block spotlighted' : 'Focus Mode off');\n    }\n    focusBtn.addEventListener('click', toggleFocus);\n\n    // Theme toggle\n    themeBtn.addEventListener('click', () => {\n      const dark = document.body.classList.toggle('dark-paper');\n      themeBtn.classList.toggle('active', dark);\n    });\n\n    // Copy HTML\n    copyHtmlBtn.addEventListener('click', async () => {\n      const html = preview.innerHTML;\n      try {\n        await navigator.clipboard.writeText(html);\n        showToast('Rendered HTML copied to clipboard');\n      } catch {\n        showToast('Preview HTML ready (' + html.length + ' chars)');\n      }\n    });\n\n    // Mobile tab switcher\n    function setMobileTab(tab) {\n      workspace.dataset.mobileTab = tab;\n      tabEdit.classList.toggle('active', tab === 'edit');\n      tabPreview.classList.toggle('active', tab === 'preview');\n      tabEdit.setAttribute('aria-selected', String(tab === 'edit'));\n      tabPreview.setAttribute('aria-selected', String(tab === 'preview'));\n    }\n    tabEdit.addEventListener('click', () => setMobileTab('edit'));\n    tabPreview.addEventListener('click', () => setMobileTab('preview'));\n\n    // Input & cursor listeners\n    let saveTimer = null;\n    editor.addEventListener('input', () => {\n      render();\n      saveStatus.textContent = 'Editing…';\n      clearTimeout(saveTimer);\n      saveTimer = setTimeout(() => { saveStatus.textContent = 'Saved locally'; }, 550);\n    });\n    editor.addEventListener('keyup', updateCursorAndFocus);\n    editor.addEventListener('click', updateCursorAndFocus);\n\n    document.addEventListener('keydown', (e) => {\n      if (e.altKey && e.key.toLowerCase() === 'f') {\n        e.preventDefault();\n        toggleFocus();\n      }\n    });\n\n    // Init\n    editor.value = INITIAL_MD;\n    render();\n  </script>\n</body>\n</html>\n"
}
