  /* =================================================================
     MARKDOWN CONTENT
     ================================================================= */

  :root {
    --markdown-reading-max-width: 920px;
    --markdown-color-scheme: light;
    --markdown-bg: #ffffff;
    --markdown-text-color: #24292e;
    --markdown-border-color: #e0e0e0;
    --markdown-accent-color: #4fc3f7;
    --markdown-blockquote-color: #666666;
    --markdown-blockquote-bold-color: inherit;
    --markdown-list-marker-color: currentColor;
    --markdown-list-item-color: inherit;
    --markdown-heading-color: #24292e;
    --markdown-bold-color: inherit;
    --markdown-bold-weight: 900;
    --markdown-hr-color: #c9d1d9;
    --markdown-table-bg: #ffffff;
    --markdown-table-row-alt: #f8f9fa;
    --markdown-table-border: #e0e0e0;
    --markdown-code-pre-bg: #f6f8fa;
    --markdown-code-inline-bg: #FFF8EC;
    --markdown-code-inline-color: #8B4500;
    --markdown-code-inline-font-weight: 600;
    --markdown-code-header-bg: rgba(0, 0, 0, 0.03);
    --markdown-code-header-border: rgba(0, 0, 0, 0.08);
    --markdown-code-block-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --markdown-code-block-hover-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    --markdown-copy-code-btn-hover-bg: #e0e0e0;
    --markdown-copy-code-btn-active-bg: #d0d0d0;
    --markdown-copy-code-btn-copied-bg: #e0e0e0;
    --markdown-hljs-color: inherit;
    --markdown-mermaid-border-color: transparent;
  }

  :root[data-theme="dark"],
  :root.dark {
    --markdown-color-scheme: dark;
    --markdown-bg: #000000;
    --markdown-text-color: #e6edf3;
    --markdown-border-color: #1a1a1a;
    --markdown-accent-color: #4fc3f7;
    --markdown-blockquote-color: #cccccc;
    --markdown-blockquote-bold-color: #E2E8F0;
    --markdown-list-marker-color: #e6edf3;
    --markdown-list-item-color: #e6edf3;
    --markdown-heading-color: #f0f3f6;
    --markdown-bold-color: #f0f3f6;
    --markdown-bold-weight: 900;
    --markdown-hr-color: #30363d;
    --markdown-table-bg: #0f1318;
    --markdown-table-row-alt: #141a22;
    --markdown-table-border: #30363d;
    --markdown-code-pre-bg: #242628;
    --markdown-code-inline-bg: #29241E;
    --markdown-code-inline-color: #FFD085;
    --markdown-code-inline-font-weight: 400;
    --markdown-code-header-bg: rgba(255, 255, 255, 0.05);
    --markdown-code-header-border: rgba(255, 255, 255, 0.1);
    --markdown-code-block-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --markdown-code-block-hover-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    --markdown-copy-code-btn-hover-bg: #3a3a3a;
    --markdown-copy-code-btn-active-bg: #4a4a4a;
    --markdown-copy-code-btn-copied-bg: #3a3a3a;
    --markdown-hljs-color: #e8eaed;
    --markdown-mermaid-border-color: rgba(255, 255, 255, 0.14);
  }

  .markdown-body {
    width: 100%;
    color-scheme: var(--markdown-color-scheme);
    background-color: var(--markdown-bg);
    color: var(--markdown-text-color);
    box-sizing: border-box;
    min-width: 200px;
    max-width: 800px;
    margin: 0 auto;
    padding: 45px;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 1.05rem;
    line-height: 1.4;
    overflow-x: hidden;
    --color-prettylights-syntax-comment: #6a737d;
    --color-prettylights-syntax-constant: #005cc5;
    --color-prettylights-syntax-entity: #6f42c1;
    --color-prettylights-syntax-storage-modifier-import: #24292e;
    --color-prettylights-syntax-entity-tag: #22863a;
    --color-prettylights-syntax-keyword: #d73a49;
    --color-prettylights-syntax-string: #032f62;
    --color-prettylights-syntax-variable: #e36209;
    --color-prettylights-syntax-brackethighlighter-unmatched: #b31d28;
    --color-prettylights-syntax-invalid-illegal-text: #fafbfc;
    --color-prettylights-syntax-invalid-illegal-bg: #b31d28;
    --color-prettylights-syntax-carriage-return-text: #fafbfc;
    --color-prettylights-syntax-carriage-return-bg: #d73a49;
    --color-prettylights-syntax-string-regexp: #22863a;
    --color-prettylights-syntax-markup-list: #735c0f;
    --color-prettylights-syntax-markup-heading: #005cc5;
    --color-prettylights-syntax-markup-italic: #24292e;
    --color-prettylights-syntax-markup-bold: #24292e;
    --color-prettylights-syntax-markup-deleted-text: #b31d28;
    --color-prettylights-syntax-markup-deleted-bg: #ffeef0;
    --color-prettylights-syntax-markup-inserted-text: #22863a;
    --color-prettylights-syntax-markup-inserted-bg: #f0fff4;
    --color-prettylights-syntax-markup-changed-text: #e36209;
    --color-prettylights-syntax-markup-changed-bg: #ffebda;
    --color-prettylights-syntax-markup-ignored-text: #f6f8fa;
    --color-prettylights-syntax-markup-ignored-bg: #005cc5;
    --color-prettylights-syntax-meta-diff-range: #6f42c1;
    --color-prettylights-syntax-brackethighlighter-angle: #586069;
    --color-prettylights-syntax-sublimelinter-gutter-mark: #e1e4e8;
    --color-prettylights-syntax-constant-other-reference-link: #032f62;
    --color-fg-default: #24292e;
    --color-fg-muted: #586069;
    --color-fg-subtle: #6a737d;
    --color-canvas-default: #ffffff;
    --color-canvas-subtle: #f6f8fa;
    --color-border-default: #e1e4e8;
    --color-border-muted: #eaecef;
    --color-neutral-muted: rgba(175,184,193,0.2);
    --color-accent-fg: #0366d6;
    --color-accent-emphasis: #0366d6;
    --color-attention-subtle: #fff5b1;
    --color-danger-fg: #d73a49;
  }

  :root[data-theme="dark"] .markdown-body,
  :root.dark .markdown-body {
    --color-prettylights-syntax-comment: #8b949e;
    --color-prettylights-syntax-constant: #79c0ff;
    --color-prettylights-syntax-entity: #d2a8ff;
    --color-prettylights-syntax-storage-modifier-import: #c9d1d9;
    --color-prettylights-syntax-entity-tag: #7ee787;
    --color-prettylights-syntax-keyword: #ff7b72;
    --color-prettylights-syntax-string: #a5d6ff;
    --color-prettylights-syntax-variable: #ffa657;
    --color-prettylights-syntax-brackethighlighter-unmatched: #f85149;
    --color-prettylights-syntax-invalid-illegal-text: #f0f6fc;
    --color-prettylights-syntax-invalid-illegal-bg: #8e1519;
    --color-prettylights-syntax-carriage-return-text: #f0f6fc;
    --color-prettylights-syntax-carriage-return-bg: #b62324;
    --color-prettylights-syntax-string-regexp: #7ee787;
    --color-prettylights-syntax-markup-list: #f2cc60;
    --color-prettylights-syntax-markup-heading: #1f6feb;
    --color-prettylights-syntax-markup-italic: #c9d1d9;
    --color-prettylights-syntax-markup-bold: #f0f3f6;
    --color-prettylights-syntax-markup-deleted-text: #ffdcd7;
    --color-prettylights-syntax-markup-deleted-bg: #67060c;
    --color-prettylights-syntax-markup-inserted-text: #aff5b4;
    --color-prettylights-syntax-markup-inserted-bg: #033a16;
    --color-prettylights-syntax-markup-changed-text: #ffdfb6;
    --color-prettylights-syntax-markup-changed-bg: #5a1e02;
    --color-prettylights-syntax-markup-ignored-text: #c9d1d9;
    --color-prettylights-syntax-markup-ignored-bg: #1158c7;
    --color-prettylights-syntax-meta-diff-range: #d2a8ff;
    --color-prettylights-syntax-brackethighlighter-angle: #8b949e;
    --color-prettylights-syntax-sublimelinter-gutter-mark: #484f58;
    --color-prettylights-syntax-constant-other-reference-link: #a5d6ff;
    --color-fg-default: #c9d1d9;
    --color-fg-muted: #8b949e;
    --color-fg-subtle: #484f58;
    --color-canvas-default: #0d1117;
    --color-canvas-subtle: #161b22;
    --color-border-default: #30363d;
    --color-border-muted: #21262d;
    --color-neutral-muted: rgba(110,118,129,0.4);
    --color-accent-fg: #58a6ff;
    --color-accent-emphasis: #1f6feb;
    --color-attention-subtle: rgba(187,128,9,0.15);
    --color-danger-fg: #f85149;
  }

  /* Normalize heading spacing across themes */
  .markdown-body h1,
  .markdown-body h2,
  .markdown-body h3,
  .markdown-body h4,
  .markdown-body h5,
  .markdown-body h6 {
    margin-top: 2rem;
    margin-bottom: 1rem;
  }

  /* Slightly larger, document-like scale when in preview-only mode */
  body.preview-only-active .markdown-body,
  body.marktide-html-document .markdown-body {
    max-width: var(--markdown-reading-max-width);
  }

  /* Screen documents respond to their reading area, including split Preview. */
  @media screen {
    .preview-pane,
    .marktide-html-reading-area {
      container: marktide-document / inline-size;
      padding: 20px;
      box-sizing: border-box;
    }

    .marktide-html-reading-area { width: 100%; }

    .markdown-body h1 { font-size: 2.1em; }
    .markdown-body h2 { font-size: 1.7em; }
    .markdown-body h3 { font-size: 1.4em; }

    @container marktide-document (max-width: 800px) {
      .markdown-body {
        padding-inline: 20px;
      }

      .markdown-body h1 { font-size: 2em; }
      .markdown-body h2 { font-size: 1.5em; }
      .markdown-body h3 { font-size: 1.25em; }
    }

    @container marktide-document (max-width: 600px) {
      .markdown-body {
        font-size: 1rem;
        padding-inline: 16px;
      }

      .markdown-body h1 { font-size: 1.65em; }
      .markdown-body h2 { font-size: 1.4em; }
      .markdown-body h3 { font-size: 1.2em; }
      .markdown-body h4 { font-size: 1.05em; }
      .markdown-body h5 { font-size: 1em; }
      .markdown-body h6 { font-size: 0.95em; }
    }
  }

  @media screen and (max-width: 600px) {
    .preview-pane,
    .marktide-html-reading-area {
      padding-inline: 0;
    }
  }

  @media screen and (max-width: 768px) {
    .markdown-body {
      padding-block: 20px;
    }
  }
  
  .markdown-body img {
    background-color: transparent !important;
  }

  /* Standalone images share one size and alignment in every output. */
  .markdown-body img.marktide-content-image {
    display: block;
    box-sizing: border-box;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

  .markdown-body img.marktide-content-image:not([height]) {
    height: auto;
  }

  .markdown-body img.marktide-default-image {
    max-width: 85%;
    height: auto;
  }

  .markdown-body .marktide-image-figure {
    margin: 0 0 16px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .markdown-body .marktide-image-caption {
    margin-top: 0.5em;
    color: var(--markdown-blockquote-color);
    font-size: 0.9em;
    font-style: italic;
    text-align: center;
    overflow-wrap: anywhere;
  }

  .markdown-body img[src*="img.shields.io"] {
    display: block;
    width: fit-content;
    max-width: 100%;
    height: auto;
    margin-bottom: 12px;
    border-radius: 6px;
    image-rendering: auto;
  }

  .markdown-body img[src*="img.shields.io"]:last-of-type {
    margin-bottom: 0;
  }

  .markdown-body p:has(img[src*="img.shields.io"]) {
    margin: 12px 0;
    line-height: 1;
  }

  .markdown-body p:has(img[src*="img.shields.io"]) br {
    display: none;
  }
  
  /* --- Lists --- */
  .markdown-body ul {
    list-style-type: disc;
    padding-left: 2.2em;
  }

  .markdown-body ul li::marker {
    color: var(--markdown-list-marker-color, currentColor);
  }
  
  .markdown-body ol,
  .markdown-body ol ol {
    list-style: none !important;
    padding-left: 2.2em;
    margin-left: 0;
    counter-reset: item;
  }

  .markdown-body ol li {
    list-style: none !important;
    color: var(--markdown-list-item-color, inherit);
  }

  .markdown-body ol li::marker {
    content: "" !important;
  }

  .markdown-body ol > li {
    counter-increment: item;
    position: relative;
  }

  .markdown-body ol > li::before {
    content: counters(item, ".") ". ";
    position: absolute;
    left: -2.2em;
    width: 2.2em;
    padding-right: 0.2em;
    box-sizing: border-box;
    text-align: right;
    font-weight: 600;
    color: var(--markdown-list-marker-color, currentColor);
  }
  
  .markdown-body li {
    margin-bottom: 0.25em;
  }
  
  .markdown-body li > p {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
  }

  .markdown-body .footnotes {
    margin-top: 2rem;
    font-size: 0.92em;
  }

  .markdown-body .footnotes ol {
    list-style: decimal !important;
    counter-reset: none;
    padding-left: 2em;
  }

  .markdown-body .footnotes ol li {
    list-style: decimal !important;
  }

  .markdown-body .footnotes ol li::marker {
    content: normal !important;
  }

  .markdown-body .footnotes ol > li {
    counter-increment: none;
  }

  .markdown-body .footnotes ol > li::before {
    content: none !important;
  }

  .markdown-body .footnote-ref {
    font-size: 0.8em;
    line-height: 0;
  }

  .markdown-body .footnote-backref {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25em;
    height: 1.25em;
    margin-left: 0.2em;
    border-radius: 4px;
    color: #8b7cff;
    font-size: 0.9em;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    vertical-align: 0.05em;
    background: transparent;
  }

  .markdown-body .footnote-backref:hover {
    color: #a99fff;
    background: rgba(139, 124, 255, 0.14);
    text-decoration: none;
  }
  
  /* --- Block Elements --- */
  .markdown-body blockquote {
    color: var(--markdown-blockquote-color, #cccccc);
    border-left: 4px solid var(--markdown-accent-color);
    padding-left: 1em;
    margin: 1em 0;
  }

  .markdown-body strong,
  .markdown-body b {
    font-weight: var(--markdown-bold-weight, 900) !important;
    color: var(--markdown-bold-color, inherit) !important;
    font-style: normal !important;
  }

  .markdown-body strong em,
  .markdown-body strong i,
  .markdown-body b em,
  .markdown-body b i {
    font-weight: var(--markdown-bold-weight, 900) !important;
    color: var(--markdown-bold-color, inherit) !important;
  }

  .markdown-body blockquote strong,
  .markdown-body blockquote b {
    font-weight: var(--blockquote-bold-weight, 700) !important;
    color: var(--markdown-blockquote-bold-color, var(--markdown-bold-color, inherit)) !important;
  }
  
  .markdown-body hr {
    background-color: var(--markdown-hr-color, color-mix(in srgb, var(--markdown-text-color) 38%, transparent));
    border: none;
    height: 2px;
    margin: 30px 0;
    opacity: 1;
  }

  .markdown-body mark {
    background-color: #fff3a3;
    color: #24292e;
    padding: 0.08em 0.18em;
    border-radius: 3px;
  }

  .markdown-body abbr[title] {
    text-decoration: underline dotted currentColor;
    text-underline-offset: 0.18em;
    cursor: help;
  }
  
  .markdown-body h1,
  .markdown-body h2,
  .markdown-body h3,
  .markdown-body h4,
  .markdown-body h5,
  .markdown-body h6 {
    font-weight: 900;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    color: var(--markdown-heading-color, var(--markdown-text-color));
  }

  .markdown-body h1,
  .markdown-body h2 {
    padding-bottom: 0.2em;
    border-bottom: 1px solid color-mix(in srgb, var(--markdown-text-color) 24%, transparent);
  }

  /* --- Tables --- */
  .markdown-body table {
    background-color: var(--markdown-table-bg, var(--markdown-bg));
    border-color: var(--markdown-table-border, var(--markdown-border-color));
  }

  .markdown-body table tr {
    background-color: var(--markdown-table-bg, var(--markdown-bg));
    border-top: 1px solid var(--markdown-table-border, var(--markdown-border-color));
  }

  .markdown-body table tr:nth-child(2n) {
    background-color: var(--markdown-table-row-alt, color-mix(in srgb, var(--markdown-text-color) 4%, var(--markdown-bg)));
  }

  .markdown-body table th,
  .markdown-body table td {
    border: 1px solid var(--markdown-table-border, var(--markdown-border-color));
  }

  /* Screen tables scroll locally. Print export has its own preparation. */
  @media screen {
    .markdown-body .marktide-table-scroll {
      max-width: 100%;
      margin-bottom: 16px;
      overflow-x: auto;
      overscroll-behavior-x: contain;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: thin;
      scrollbar-color: var(--markdown-border-color) transparent;
    }

    .markdown-body .marktide-table-scroll::-webkit-scrollbar {
      height: 6px;
    }

    .markdown-body .marktide-table-scroll::-webkit-scrollbar-thumb {
      background: var(--markdown-border-color);
      border-radius: 3px;
    }

    .markdown-body .marktide-table-scroll:focus-visible {
      outline: 2px solid var(--markdown-accent-color);
      outline-offset: 2px;
    }

    .markdown-body .marktide-table-scroll::before {
      display: none;
    }

    @container marktide-document (max-width: 600px) {
      .markdown-body .marktide-table-scroll[data-marktide-scroll-state]:not([data-marktide-scroll-state="none"])::before {
        content: attr(data-marktide-scroll-hint);
        display: block;
        position: sticky;
        inset-inline-start: 0;
        width: fit-content;
        padding: 0 0 6px;
        color: var(--markdown-blockquote-color);
        font-size: 11px;
        line-height: 1.4;
      }
    }

    .markdown-body .marktide-table-scroll > table {
      display: table;
      width: auto;
      max-width: none;
      margin-bottom: 0;
      overflow: visible;
    }

    .markdown-body .marktide-table-scroll table,
    .markdown-body .marktide-table-scroll th,
    .markdown-body .marktide-table-scroll td {
      box-sizing: border-box;
    }

    .markdown-body .marktide-table-scroll th[align="left"] { text-align: left; }
    .markdown-body .marktide-table-scroll th[align="center"] { text-align: center; }
    .markdown-body .marktide-table-scroll th[align="right"] { text-align: right; }

    /* Keep Preview's default alignment in the standalone document too. */
    .markdown-body .marktide-table-scroll th:not([align]):not([style*="text-align"]) {
      text-align: left;
    }

    .markdown-body table.marktide-screen-balanced-table {
      width: 100%;
      min-width: var(--marktide-table-min-width);
      table-layout: fixed;
      font-size: 92%;
    }

    .markdown-body .marktide-table-scroll > table.marktide-screen-media-table {
      width: max-content;
    }

    .markdown-body table.marktide-screen-balanced-table th,
    .markdown-body table.marktide-screen-balanced-table td {
      padding: 5px 7px;
    }

    .markdown-body table .marktide-screen-long-value,
    .markdown-body table .marktide-screen-long-value code:not(pre code),
    .markdown-body table .marktide-screen-long-value a {
      overflow-wrap: anywhere;
      word-break: normal;
      white-space: normal;
    }

    /* Compact only larger grids when the reading area is narrow. */
    @container marktide-document (max-width: 600px) {
      .markdown-body table.marktide-screen-compact-table {
        font-size: 87.5%;
      }

      .markdown-body table.marktide-screen-balanced-table,
      .markdown-body table.marktide-screen-mobile-balanced-table {
        width: 100%;
        table-layout: fixed;
        min-width: var(--marktide-table-mobile-min-width);
      }

      .markdown-body .marktide-screen-columns col {
        width: var(--marktide-mobile-column-width) !important;
      }

      .markdown-body table.marktide-screen-compact-table th,
      .markdown-body table.marktide-screen-compact-table td {
        padding: 6px 8px;
      }

      .markdown-body table.marktide-screen-compact-table th:not(.marktide-screen-long-value),
      .markdown-body table.marktide-screen-compact-table td:not(.marktide-screen-long-value) {
        overflow-wrap: normal;
        word-break: normal;
      }

      .markdown-body table.marktide-screen-compact-table .marktide-screen-short-value,
      .markdown-body table.marktide-screen-compact-table code.marktide-screen-short-code {
        white-space: nowrap;
      }
    }
  }

  @media print {
    .markdown-body .marktide-table-scroll {
      display: contents;
    }

    .markdown-body .marktide-table-scroll::before {
      display: none;
    }
  }
  
  /* --- Enhanced Code Blocks --- */
  .enhanced-code-block {
    background-color: var(--markdown-code-pre-bg, #f6f8fa);
    border-radius: 12px;
    margin: 1.5em 0;
    overflow: hidden;
    border: 1px solid var(--markdown-border-color, #e1e4e8);
    box-shadow: var(--markdown-code-block-shadow, 0 4px 12px rgba(0, 0, 0, 0.1));
    transition: all 0.2s ease;
  }

  .enhanced-code-block:hover {
    box-shadow: var(--markdown-code-block-hover-shadow, 0 6px 20px rgba(0, 0, 0, 0.15));
    transform: translateY(-1px);
  }

  .code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 16px;
    background: var(--markdown-code-header-bg, rgba(0, 0, 0, 0.05));
    border-bottom: 1px solid var(--markdown-code-header-border, rgba(0, 0, 0, 0.1));
    font-size: 13px;
    font-weight: 500;
  }

  .code-language {
    color: var(--markdown-text-color, #24292e);
    font-family: "Fira Code", "JetBrains Mono", "Consolas", "Monaco", "Lucida Console", monospace;
    text-transform: lowercase;
    opacity: 0.8;
    font-weight: 600;
    letter-spacing: 0.5px;
  }

  .code-block-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
  }

  /* Preview code header: Grok-style hover/focus hints (fine pointer only; touch has no hover) */
  .markdown-body .code-block-header-actions [data-marktide-tip] {
    position: relative;
  }

  .markdown-body .code-block-header-actions [data-marktide-tip]::after {
    content: attr(data-marktide-tip);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    z-index: 60;
    padding: 0.32rem 0.55rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.01em;
    white-space: nowrap;
    color: #f3f4f8;
    background: rgba(22, 24, 30, 0.96);
    border: 1px solid color-mix(in srgb, var(--markdown-border-color) 45%, transparent);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.38);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-3px);
    transition:
      opacity 0.12s ease,
      transform 0.12s ease,
      visibility 0.12s ease;
  }

  .markdown-body .code-block-header-actions [data-marktide-tip]:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
  }

  /* Preview-only wrap control (long lines): Grok-style icons, shown only when overflow or while wrapped */
  .markdown-body .wrap-code-btn {
    display: none;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--markdown-text-color, #24292e);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.15s ease, transform 0.1s ease;
  }

  .markdown-body .wrap-code-btn.wrap-code-btn--show {
    display: flex;
  }

  .markdown-body .wrap-code-btn:hover {
    opacity: 1;
  }

  .markdown-body .wrap-code-btn:active {
    transform: scale(0.92);
  }

  .markdown-body .wrap-code-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
  }

  .markdown-body .wrap-code-svg {
    width: 16px;
    height: 16px;
    display: block;
  }

  .markdown-body .enhanced-code-block:not(.is-wrapped) .wrap-code-icon--unwrap {
    display: none !important;
  }

  .markdown-body .enhanced-code-block.is-wrapped .wrap-code-icon--wrap {
    display: none !important;
  }

  .markdown-body .enhanced-code-block.is-wrapped > pre {
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .markdown-body .enhanced-code-block.is-wrapped > pre code.hljs {
    white-space: pre-wrap !important;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .enhanced-code-block .copy-code-btn {
    background: transparent;
    border: none;
    border-radius: 50%; /* Circular shape */
    color: var(--markdown-text-color, #24292e);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    font-size: 16px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
  }

  .enhanced-code-block .copy-code-btn:hover {
    background: var(--markdown-copy-code-btn-hover-bg, #e0e0e0) !important;
    color: var(--markdown-text-color, #24292e) !important;
    border-radius: 50% !important;
    opacity: 1;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
  }

  .enhanced-code-block .copy-code-btn:active {
    background: var(--markdown-copy-code-btn-active-bg, #d0d0d0);
    transform: scale(0.9);
    transition: transform 0.1s ease;
  }

  .enhanced-code-block .copy-code-btn.copied {
    background: var(--markdown-copy-code-btn-copied-bg, var(--markdown-copy-code-btn-hover-bg, #e0e0e0)) !important;
    color: var(--markdown-text-color, #24292e) !important;
    opacity: 1;
  }

  .enhanced-code-block .copy-code-btn.error {
    background: rgba(244, 67, 54, 0.15);
    color: #f44336;
  }

  .enhanced-code-block pre {
    background: transparent;
    border-radius: 0;
    padding: 16px;
    margin: 0;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    font-family: "Fira Code", "JetBrains Mono", "Consolas", "Monaco", "Lucida Console", monospace;
    font-feature-settings: "liga" 1, "calt" 1;
  }
  
  .enhanced-code-block pre code,
  .enhanced-code-block pre code.hljs {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-family: "Fira Code", "JetBrains Mono", "Consolas", "Monaco", "Lucida Console", monospace;
    font-feature-settings: "liga" 1, "calt" 1;
  }

  /* Legacy code blocks (fallback) */
  .markdown-body pre:not(.enhanced-code-block pre) {
    background-color: var(--markdown-code-pre-bg, #f6f8fa);
    border-radius: 6px;
    padding: 16px;
    margin: 1.5em 0;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    font-family: "Fira Code", "JetBrains Mono", "Consolas", "Monaco", "Lucida Console", monospace;
    font-feature-settings: "liga" 1, "calt" 1;
  }
  
  .markdown-body pre:not(.enhanced-code-block pre) code,
  .markdown-body pre:not(.enhanced-code-block pre) code.hljs {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-family: "Fira Code", "JetBrains Mono", "Consolas", "Monaco", "Lucida Console", monospace;
    font-feature-settings: "liga" 1, "calt" 1;
  }
  
  .markdown-body code {
    background-color: var(--markdown-code-inline-bg, #f6f8fa);
    color: var(--markdown-code-inline-color, #24292e);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 85%;
    font-family: "Fira Code", "JetBrains Mono", "Consolas", "Monaco", "Lucida Console", monospace;
    font-feature-settings: "liga" 1, "calt" 1;
  }

  @media screen {
    .markdown-body .enhanced-code-block pre:focus-visible,
    .markdown-body .code-block-header-actions button:focus-visible {
      outline: 2px solid var(--markdown-accent-color);
      outline-offset: -3px;
    }

    @container marktide-document (max-width: 600px) {
      .markdown-body .enhanced-code-block {
        border-radius: 8px;
        margin-block: 1em;
        box-shadow: none;
        transform: none;
        transition: none;
      }

      .markdown-body .code-block-header {
        padding: 2px 12px;
        font-size: 12px;
        gap: 8px;
      }

      .markdown-body .code-language {
        min-width: 0;
        overflow-wrap: anywhere;
      }

      .markdown-body .code-block-header-actions {
        flex-shrink: 0;
      }

      .markdown-body .enhanced-code-block pre,
      .markdown-body pre:not(.enhanced-code-block pre) {
        padding: 12px;
        font-size: 13px;
        overscroll-behavior-x: contain;
      }

      /* Keep the same readable size for code and highlighted spans. */
      .markdown-body pre code,
      .markdown-body pre code.hljs {
        font-size: inherit;
      }
    }
  }

  @media screen and (hover: none) and (pointer: coarse) {
    .markdown-body .code-block-header-actions button {
      width: 44px;
      height: 44px;
      opacity: 0.85;
    }

    .markdown-body .enhanced-code-block:hover {
      transform: none;
      box-shadow: var(--markdown-code-block-shadow);
    }

    .markdown-body pre {
      scrollbar-color: var(--markdown-border-color) transparent;
    }

    .markdown-body pre::-webkit-scrollbar-thumb {
      background: var(--markdown-border-color);
    }

    @container marktide-document (max-width: 600px) {
      .markdown-body .enhanced-code-block:hover {
        box-shadow: none;
      }
    }
  }

  .markdown-body code:not(pre code) {
    padding-top: 0.1em;
    padding-bottom: 0.1em;
    font-weight: var(--markdown-code-inline-font-weight, 600);
  }

  .markdown-body .hljs {
    color: var(--markdown-hljs-color, inherit);
  }

  /* hljs themes (CDN) use `pre code.hljs { overflow-x: auto }`, which attaches the scrollbar to
     <code> (see DevTools). Turn that off so <pre> is the scroll container and slim ::-webkit
     rules below actually apply. */
  .markdown-body pre code.hljs {
    display: block;
    overflow-x: visible !important;
    overflow-y: visible !important;
  }

  /* Code fences and Mermaid diagrams: slim scrollbars hidden until hover */
  .markdown-body pre,
  .markdown-body .mermaid-container,
  .markdown-body .mermaid {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    scrollbar-gutter: stable;
    transition: scrollbar-color 0.2s ease;
  }

  .markdown-body pre:hover,
  .markdown-body .mermaid-container:hover,
  .markdown-body .mermaid:hover {
    scrollbar-color: rgba(79, 195, 247, 0.55) transparent;
  }

  .markdown-body pre::-webkit-scrollbar,
  .markdown-body .mermaid-container::-webkit-scrollbar,
  .markdown-body .mermaid::-webkit-scrollbar {
    width: 4px;
    height: 4px;
    background: transparent;
  }

  .markdown-body pre::-webkit-scrollbar-button,
  .markdown-body .mermaid-container::-webkit-scrollbar-button,
  .markdown-body .mermaid::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
  }

  .markdown-body pre::-webkit-scrollbar-track,
  .markdown-body .mermaid-container::-webkit-scrollbar-track,
  .markdown-body .mermaid::-webkit-scrollbar-track {
    background: transparent;
    border: 0;
  }

  .markdown-body pre::-webkit-scrollbar-thumb,
  .markdown-body .mermaid-container::-webkit-scrollbar-thumb,
  .markdown-body .mermaid::-webkit-scrollbar-thumb {
    background: transparent;
    border: 0;
    border-radius: 999px;
    transition: background-color 0.2s ease;
  }

  .markdown-body pre:hover::-webkit-scrollbar-thumb,
  .markdown-body .mermaid-container:hover::-webkit-scrollbar-thumb,
  .markdown-body .mermaid:hover::-webkit-scrollbar-thumb {
    background: rgba(79, 195, 247, 0.55);
  }

  .markdown-body pre:hover::-webkit-scrollbar-thumb:hover,
  .markdown-body .mermaid-container:hover::-webkit-scrollbar-thumb:hover,
  .markdown-body .mermaid:hover::-webkit-scrollbar-thumb:hover {
    background: rgba(79, 195, 247, 0.8);
  }

  .markdown-body pre::-webkit-scrollbar-corner,
  .markdown-body .mermaid-container::-webkit-scrollbar-corner,
  .markdown-body .mermaid::-webkit-scrollbar-corner {
    background: transparent;
  }

  
  /* =================================================================
     MERMAID DIAGRAM CONTENT
     ================================================================= */
  
  .mermaid-container {
    position: relative;
  }

  .mermaid-container, .mermaid {
    text-align: center;
    margin: 1em 0;
    overflow-x: auto;
    overflow-y: visible;
    max-width: 100%;
  }

  .markdown-body .mermaid-container {
    background: #ffffff;
    border: 1px solid var(--markdown-mermaid-border-color);
    border-radius: 6px;
    padding: 16px;
  }

  .mermaid svg {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    overflow: visible;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  }

  .mermaid .node rect,
  .mermaid .node circle,
  .mermaid .node ellipse,
  .mermaid .node polygon {
    stroke-width: 1px;
  }

  .mermaid .nodeLabel,
  .mermaid .edgeLabel,
  .mermaid .label,
  .mermaid text {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif !important;
  }

