/* ═══════════════════════════════════════════════════
   RENDERED MARKDOWN
═══════════════════════════════════════════════════ */
:is(#_sd_rendered, #_sd_write) {
  padding: 40px 48px 60px;
  max-width: 760px;
  margin: 0 auto;

  --md-bg:             #FFFFFF;
  --md-font-family:    'Inter', system-ui, sans-serif;
  --md-base-size:      16px;
  --md-line-height:    1.75;
  --md-color:          #1C1917;
  --md-h-font-family:  inherit;
  --md-h-scale:        1;
  --md-h-margin-bottom: 0.4em;
  --md-h-color:        var(--md-color);
  --md-h1-size:        2.1em;
  --md-h1-color:       var(--md-h-color);
  --md-h1-margin:      0 0 0.3em;
  --md-h1-weight:      700;
  --md-h2-size:        1.55em;
  --md-h2-color:       var(--md-h-color);
  --md-h2-margin:      1.4em 0 0.3em;
  --md-h2-weight:      600;
  --md-h3-size:        1.2em;
  --md-h3-color:       var(--md-h-color);
  --md-h3-margin:      1.2em 0 0.3em;
  --md-h3-weight:      600;
  --md-h4-size:        1.0em;
  --md-h4-color:       var(--md-h-color);
  --md-h4-margin:      1.0em 0 0.25em;
  --md-h4-weight:      600;
  --md-p-color:        var(--md-color);
  --md-list-color:     var(--md-p-color);
  --md-list-spacing:   0.3em;
  --md-list-indent:    1.6em;
  --md-p-line-height:  var(--md-line-height);
  /* --md-block-gap is the document's vertical rhythm. Paragraphs, code-block
     wrappers, and comment cards all separate from neighbors by this amount. */
  --md-block-gap:      1.1em;
  --md-p-margin:       0 0 var(--md-block-gap);
  /* --card-attach-gap is the small space between a commented block and its
     card. Smaller than --md-block-gap so the card reads as attached above. */
  --card-attach-gap:   0.35em;
  --md-link-color:     #2563EB;
  --md-link-decoration: underline;
  --md-code-bg:        #F4F1ED;
  --md-code-color:     #6B21A8;
  --md-code-padding:   0.15em 0.45em;
  --md-code-radius:    4px;
  --md-code-font:      'JetBrains Mono', 'Fira Mono', monospace;
  --md-pre-bg:         #F4F1ED;
  --md-pre-padding:    1.1em 1.25em;
  --md-bq-border:      3px solid #2563EB;
  --md-bq-size:        1.05em;
  --md-bq-color:       #6B6560;
  --md-bq-padding:     0.5em 1em;
  --md-bq-margin:      1.2em 0;

  font-family: var(--md-font-family);
  font-size: var(--md-base-size);
  color: var(--md-color);
  line-height: var(--md-line-height);
  background-color: var(--md-bg);
}
:is(#_sd_rendered, #_sd_write) h1 {
  font-family: var(--md-h-font-family);
  font-size: calc(var(--md-h1-size) * var(--md-h-scale));
  color: var(--md-h1-color);
  margin: var(--md-h1-margin);
  font-weight: var(--md-h1-weight);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
/* Subsequent H1s mark a new major section — give them real breathing room */
:is(#_sd_rendered, #_sd_write) h1:not(:first-of-type) {
  margin-top: 2em;
}
:is(#_sd_rendered, #_sd_write) h2 {
  font-family: var(--md-h-font-family);
  font-size: calc(var(--md-h2-size) * var(--md-h-scale));
  color: var(--md-h2-color);
  margin: var(--md-h2-margin);
  font-weight: var(--md-h2-weight);
  letter-spacing: -0.015em;
  line-height: 1.3;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--md-h2-border);
}
:is(#_sd_rendered, #_sd_write) h3 {
  font-family: var(--md-h-font-family);
  font-size: calc(var(--md-h3-size) * var(--md-h-scale));
  color: var(--md-h3-color);
  margin: var(--md-h3-margin);
  font-weight: var(--md-h3-weight);
  letter-spacing: -0.01em;
  line-height: 1.4;
}
:is(#_sd_rendered, #_sd_write) h4 {
  font-family: var(--md-h-font-family);
  font-size: calc(var(--md-h4-size) * var(--md-h-scale));
  color: var(--md-h4-color);
  margin: var(--md-h4-margin);
  font-weight: var(--md-h4-weight);
  line-height: 1.5;
}
:is(#_sd_rendered, #_sd_write) p {
  color: var(--md-p-color);
  line-height: var(--md-p-line-height);
  margin: var(--md-p-margin);
}
:is(#_sd_rendered, #_sd_write) a {
  color: var(--md-link-color);
  text-decoration: var(--md-link-decoration);
  text-underline-offset: 2px;
  cursor: pointer;
}
:is(#_sd_rendered, #_sd_write) a:hover { opacity: .8; }

/* ── Collapsible heading sections ── */
/* The .sdoc-block-host variants match comment-mode, where every top-level */
/* block (incl. headings) is wrapped to host the gutter "add comment" button. */
#_sd_rendered .md-section > h2,
#_sd_rendered .md-section > h3,
#_sd_rendered .md-section > h4,
#_sd_rendered .md-section > .sdoc-block-host > h2,
#_sd_rendered .md-section > .sdoc-block-host > h3,
#_sd_rendered .md-section > .sdoc-block-host > h4 {
  cursor: pointer;
}
#_sd_rendered .section-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  cursor: pointer;
  margin-right: 4px;
  vertical-align: middle;
  transition: transform .18s cubic-bezier(.4,0,.2,1), color .12s;
  transform: rotate(0deg);
}
#_sd_rendered .section-toggle.open {
  transform: rotate(90deg);
}
#_sd_rendered .section-toggle:hover,
#_sd_rendered h1:hover > .section-toggle,
#_sd_rendered .md-section > h2:hover > .section-toggle,
#_sd_rendered .md-section > h3:hover > .section-toggle,
#_sd_rendered .md-section > h4:hover > .section-toggle,
#_sd_rendered .md-section > .sdoc-block-host > h2:hover > .section-toggle,
#_sd_rendered .md-section > .sdoc-block-host > h3:hover > .section-toggle,
#_sd_rendered .md-section > .sdoc-block-host > h4:hover > .section-toggle,
#_sd_rendered > h1:hover ~ .md-section .section-toggle,
#_sd_rendered > .sdoc-block-host:has(> h1:hover) ~ .md-section .section-toggle,
#_sd_rendered .md-section > h2:hover ~ .md-section-body .section-toggle,
#_sd_rendered .md-section > h3:hover ~ .md-section-body .section-toggle,
#_sd_rendered .md-section > h4:hover ~ .md-section-body .section-toggle,
#_sd_rendered .md-section > .sdoc-block-host:has(> h2:hover) ~ .md-section-body .section-toggle,
#_sd_rendered .md-section > .sdoc-block-host:has(> h3:hover) ~ .md-section-body .section-toggle,
#_sd_rendered .md-section > .sdoc-block-host:has(> h4:hover) ~ .md-section-body .section-toggle {
  color: var(--text-2);
}
#_sd_rendered .md-section-body:not(.open):not(:has(.md-section-body.open)) > :not(.md-section) {
  display: none;
}
#_sd_rendered .md-section-body:not(.open):not(:has(.md-section-body.open)):has(> :not(.md-section)):has(> .md-section)::before {
  content: "\2026";
  display: block;
  opacity: 1;
  font-weight: bold;
  padding-left: calc(1.2em + 20px);
  font-size: 1rem;
  color: var(--text-3);
  padding-bottom: 10px;
  line-height: 0.1;
}
#_sd_rendered .md-section-body:not(.open):has(.md-section-body.open) > :not(.md-section) {
  opacity: 0.55;
  padding-left: calc(1.2em + 20px);
}
#_sd_rendered .md-section-body:not(.open) > .md-section:not(:has(> .md-section-body.open)) {
  padding-left: 1.2em;
}
#_sd_rendered .md-section-body:not(.open) > .md-section:not(:has(> .md-section-body.open)) > h2,
#_sd_rendered .md-section-body:not(.open) > .md-section:not(:has(> .md-section-body.open)) > h3,
#_sd_rendered .md-section-body:not(.open) > .md-section:not(:has(> .md-section-body.open)) > h4,
#_sd_rendered .md-section-body:not(.open) > .md-section:not(:has(> .md-section-body.open)) > .sdoc-block-host > h2,
#_sd_rendered .md-section-body:not(.open) > .md-section:not(:has(> .md-section-body.open)) > .sdoc-block-host > h3,
#_sd_rendered .md-section-body:not(.open) > .md-section:not(:has(> .md-section-body.open)) > .sdoc-block-host > h4 {
  margin-top: 0.15em;
  margin-bottom: 0.1em;
  padding-bottom: 0;
  border-bottom: none;
  opacity: 0.55;
}

/* ── Header anchor links ── */
#_sd_rendered h1, #_sd_rendered h2, #_sd_rendered h3, #_sd_rendered h4 { position: relative; }
#_sd_rendered .header-anchor {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  opacity: 0.5;
  transition: opacity 0.15s;
  color: var(--md-link-color, #2563eb);
  cursor: pointer;
  vertical-align: middle;
}
#_sd_rendered .header-anchor:hover { opacity: 1; }
#_sd_rendered .header-copy-btn {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  opacity: 0.5;
  transition: opacity 0.15s;
  color: var(--md-link-color, #2563eb);
  cursor: pointer;
  vertical-align: middle;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  line-height: 1;
}
#_sd_rendered .header-copy-btn:hover { opacity: 1; }

/* ── Scroll padding for anchor jumps ── */
#_sd_content-area { scroll-padding-top: 24px; }

:is(#_sd_rendered, #_sd_write) code {
  background: var(--md-code-bg);
  color: var(--md-code-color);
  padding: var(--md-code-padding);
  border-radius: var(--md-code-radius);
  font-family: var(--md-code-font);
  font-size: 0.85em;
  overflow-wrap: anywhere;
}
#_sd_rendered .pre-wrapper {
  position: relative;
  margin: var(--md-block-gap) 0;
}
:is(#_sd_rendered, #_sd_write) pre {
  background: var(--md-pre-bg);
  padding: var(--md-pre-padding);
  border-radius: var(--radius-md);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  white-space: pre;
  word-wrap: normal;
  margin: 1.2em 0;
  border: 1px solid var(--md-pre-border);
}
#_sd_rendered pre {
  padding-top: 26px;
  margin: 0;
}
/* All corner buttons live in one flex cluster, top-right, so they always pack
   together with no gaps no matter which subset is present. */
#_sd_rendered .pre-wrapper .pre-tools {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 1;
}
#_sd_rendered .pre-wrapper .copy-btn,
#_sd_rendered .pre-wrapper .expand-btn,
#_sd_rendered .pre-wrapper .code-comment-btn,
#_sd_rendered .pre-wrapper .agent-comment-btn,
#_sd_rendered .pre-wrapper .wrap-btn {
  background: var(--md-pre-bg);
  border: 1px solid var(--md-copy-btn-border);
  border-radius: 4px;
  padding: 3px 5px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
  color: var(--md-code-color, #6B21A8);
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 3px;
}
/* left-to-right order within the cluster: indicators, then wrap / expand / copy */
#_sd_rendered .pre-wrapper .agent-comment-btn { order: 1; }
#_sd_rendered .pre-wrapper .code-comment-btn  { order: 2; }
#_sd_rendered .pre-wrapper .wrap-btn          { order: 3; }
#_sd_rendered .pre-wrapper .expand-btn        { order: 4; }
#_sd_rendered .pre-wrapper .copy-btn          { order: 5; }
#_sd_rendered .pre-wrapper .copy-btn:hover,
#_sd_rendered .pre-wrapper .expand-btn:hover,
#_sd_rendered .pre-wrapper .code-comment-btn:hover,
#_sd_rendered .pre-wrapper .agent-comment-btn:hover,
#_sd_rendered .pre-wrapper .wrap-btn:hover { opacity: 1; background: var(--md-copy-btn-hover); }
#_sd_rendered .pre-wrapper .wrap-btn.active { opacity: 1; background: var(--md-copy-btn-hover); }

/* Comment indicators: always shown (created only when notes exist). The icon
   keeps the standard colour; a small dot in the comment's own colour (via --dot)
   sits just inside the top-right corner. */
#_sd_rendered .pre-wrapper .code-comment-btn,
#_sd_rendered .pre-wrapper .agent-comment-btn { opacity: 1; position: relative; }
#_sd_rendered .pre-wrapper .code-comment-btn::after,
#_sd_rendered .pre-wrapper .agent-comment-btn::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dot, var(--md-code-color, #6B21A8));
  border: 1px solid var(--md-pre-bg);
}
#_sd_rendered pre.wrapped,
#_sd_rendered pre.wrapped code {
  white-space: pre-wrap;
  word-break: break-word;
}
#_sd_rendered pre.wrapped { overflow-x: hidden; }
:is(#_sd_rendered, #_sd_write) pre code {
  background: none;
  padding: 0;
  color: var(--md-code-color);
  font-family: var(--md-code-font);
  font-size: 0.88em;
  overflow: visible;
  white-space: pre;
  word-break: normal;
}

/* ── Syntax highlighting (highlight.js token classes) ──
   highlight.js emits <span class="hljs-keyword"> etc.; we colour them here
   rather than ship one of its 300 prebuilt themes, so the palette tracks our
   light/dark themes and the block background stays --md-pre-bg.

   Comments are deliberately NOT the usual washed-out grey. In a document the
   comments carry the human explanation, so they are styled to stand out -
   italic, full-contrast colour, and a faint tint - while code tokens are
   coloured but quieter. This is the "comments pop" behaviour. */
:is(#_sd_rendered, .sdoc-code-focus) {
  --hl-keyword:  #7c3aed;  /* keywords, storage, operators-as-words */
  --hl-string:   #b45309;  /* strings, regexp, char literals */
  --hl-number:   #be185d;  /* numbers, booleans, literals */
  --hl-function: #2563eb;  /* function / method names */
  --hl-type:     #0e7490;  /* classes, types, built-ins */
  --hl-meta:     #6d28d9;  /* decorators, annotations, preprocessor */
  --hl-attr:     #0369a1;  /* object keys, attributes, properties */
  --hl-tag:      #9333ea;  /* markup/HTML tag names */
  --hl-muted:    #8a857d;  /* punctuation that should recede */
  --hl-comment:  #0f766e;  /* comments - the prominent lane (see above) */
  --hl-comment-bg: rgba(15, 118, 110, 0.07);
}
html[data-theme="dark"] :is(#_sd_rendered, .sdoc-code-focus) {
  --hl-keyword:  #c4b5fd;
  --hl-string:   #fcd34d;
  --hl-number:   #f9a8d4;
  --hl-function: #93c5fd;
  --hl-type:     #67e8f9;
  --hl-meta:     #a5b4fc;  /* distinct from keyword (was a clash) */
  --hl-attr:     #7dd3fc;
  --hl-tag:      #d8b4fe;
  --hl-muted:    #9b948b;
  --hl-comment:  #5eead4;
  --hl-comment-bg: rgba(94, 234, 212, 0.10);
}

:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-keyword,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-built_in.hljs-keyword,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-literal,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-selector-tag,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-doctag { color: var(--hl-keyword); }

:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-string,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-regexp,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-char.escape_,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-symbol,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-template-tag,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-quote { color: var(--hl-string); }

:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-number,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-bullet { color: var(--hl-number); }

:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-title,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-title.function_,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-section { color: var(--hl-function); font-weight: 600; }

:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-type,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-built_in,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-class .hljs-title,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-title.class_,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-params .hljs-keyword { color: var(--hl-type); }

:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-meta,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-meta .hljs-keyword,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-meta-keyword { color: var(--hl-meta); }

:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-attr,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-attribute,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-property,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-variable,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-template-variable { color: var(--hl-attr); }

:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-tag,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-name,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-selector-id,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-selector-class { color: var(--hl-tag); }

:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-punctuation,
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-operator { color: var(--hl-muted); }

:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-deletion { color: #b91c1c; }
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-addition { color: #15803d; }

/* Comments: the prominent lane. Italic, full-contrast colour, faint tint, and
   a hair of horizontal padding so a trailing `# note` reads as its own thing. */
:is(#_sd_rendered pre code, .sdoc-code-focus) .hljs-comment {
  color: var(--hl-comment);
  background: var(--hl-comment-bg);
  font-style: italic;
  border-radius: 3px;
  padding: 0 0.25em;
}

:is(#_sd_rendered, #_sd_write) ul, :is(#_sd_rendered, #_sd_write) ol {
  padding-left: var(--md-list-indent);
  margin: 0.5em 0 1.1em;
}
:is(#_sd_rendered, #_sd_write) li { margin-bottom: var(--md-list-spacing); color: var(--md-list-color); }
:is(#_sd_rendered, #_sd_write) li::marker { color: var(--md-list-color); }
:is(#_sd_rendered, #_sd_write) hr {
  border: none;
  border-top: 1px solid var(--md-hr-border);
  margin: 2em 0;
}
:is(#_sd_rendered, #_sd_write) img { max-width: 100%; border-radius: var(--radius-md); }

/* ── File-info card (shown when front matter has `file:`) ─────────── */
/* Matches the dimensions and inner padding of #_sd_rendered so values line up
   exactly with the document text. No background, border, or shadow — reads
   as plain header text above the document. */
#_sd_sdocs-file-info[hidden] { display: none; }
#_sd_sdocs-file-info {
  /* Mirror the light-mode document defaults so card text matches body text
     even when no controls have fired. setStyleVar also mirrors any user
     overrides onto this element (see sdocs-state.js). */
  --md-color: #1C1917;
  --md-p-color: var(--md-color);
  --fic-muted: color-mix(in srgb, var(--md-p-color) 40%, transparent);
  --fic-hover: color-mix(in srgb, var(--md-p-color) 10%, transparent);

  max-width: 760px;
  margin: 0 auto;
  padding: 28px 48px 0;
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--fic-muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#_sd_sdocs-file-info:not([hidden]) + #_sd_rendered,
#_sd_sdocs-file-info:not([hidden]) ~ #_sd_write { padding-top: 32px; }
#_sd_sdocs-file-info .fic-rows {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--md-hr-border);
}
#_sd_sdocs-file-info .fic-rows[hidden] { display: none; }
#_sd_sdocs-file-info .fic-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 5px 0;
  line-height: 1.5;
  border-top: 1px solid color-mix(in srgb, var(--fic-text) 10%, transparent);
  cursor: pointer;
}
#_sd_sdocs-file-info .fic-row:hover .fic-copy { color: var(--md-p-color); }
#_sd_sdocs-file-info .fic-row:first-child { border-top: none; }
#_sd_sdocs-file-info .fic-label {
  color: var(--fic-muted);
  flex-shrink: 0;
  min-width: 58px;
  font-weight: 500;
}
#_sd_sdocs-file-info .fic-value {
  flex: 1;
  min-width: 0;
  color: var(--md-p-color);
  overflow-wrap: anywhere;
  word-break: break-word;
}
#_sd_sdocs-file-info .fic-local-tag {
  font-size: 11px;
  color: var(--fic-muted);
  flex-shrink: 0;
}
/* Inline "live" chip rendered next to the filename in non-editing
   modes, only when the bridge is actively syncing. Reuses the muted
   tone of .fic-local-tag so it reads as ambient state, not an alert. */
#_sd_sdocs-file-info .fic-live-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px 1px 6px;
  border: 1px solid color-mix(in srgb, var(--fic-muted) 35%, transparent);
  border-radius: 999px;
  font-size: 11px;
  color: var(--fic-muted);
  cursor: default;
  flex-shrink: 0;
}
#_sd_sdocs-file-info .fic-live-chip svg { color: var(--fic-muted); }
#_sd_sdocs-file-info .fic-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: transparent;
  border: none;
  color: var(--fic-muted);
  border-radius: var(--radius-sm);
  padding: 0;
  cursor: pointer;
  transition: background .12s, color .12s;
}
/* Icon shouldn't swallow pointer events; the button does. Keeps e.target
   as the button itself so delegated row click handlers behave consistently. */
#_sd_sdocs-file-info .fic-copy svg,
#_sd_sdocs-file-info .fic-copy svg * { pointer-events: none; }
#_sd_sdocs-file-info .fic-copy:hover {
  color: var(--md-p-color);
}
/* Tags row: chips in the value column, + button in the right-hand icon
   slot like the copy buttons on other rows. When the file is on disk
   and the library agent is reachable, chips show a × control and the
   + opens an inline composer with suggestions from this project. */
#_sd_sdocs-file-info .fic-row-tags {
  cursor: default;
  align-items: flex-start;
}
#_sd_sdocs-file-info .fic-row-tags .fic-value {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  font-family: inherit;
}
#_sd_sdocs-file-info .fic-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 8px;
  background: var(--md-pre-bg, rgba(0,0,0,0.04));
  border: 1px solid var(--md-copy-btn-border, rgba(0,0,0,0.08));
  border-radius: 999px;
  font-family: var(--md-code-font);
  font-size: 11.5px;
  color: var(--md-code-color, var(--md-p-color));
  line-height: 1.4;
}
#_sd_sdocs-file-info .fic-tag-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  color: var(--fic-muted);
  cursor: pointer;
  /* Always visible (subtle), pops on hover. The user asked for this so
     the right edge of each chip doesn't leave a blank gap. */
  opacity: .45;
  transition: opacity .12s, color .12s, background .12s;
}
#_sd_sdocs-file-info .fic-tag-chip:hover .fic-tag-x { opacity: .8; }
#_sd_sdocs-file-info .fic-tag-x:hover {
  opacity: 1; color: var(--md-p-color);
  background: var(--md-copy-btn-hover, rgba(0,0,0,0.08));
}
/* + button: sits in the icon slot on the right of the row, same look
   as the copy buttons. */
#_sd_sdocs-file-info .fic-tag-add {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--fic-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color .12s, background .12s;
}
#_sd_sdocs-file-info .fic-tag-add:hover {
  color: var(--md-p-color);
  background: var(--md-copy-btn-hover, rgba(0,0,0,0.06));
}
#_sd_sdocs-file-info .fic-row-tags-composing .fic-tag-add {
  visibility: hidden; /* keep its slot so the row width stays steady */
}
/* Faint hint shown in the read-only Tags row when the file is on disk
   but no Bridge is alive - tells the user how to enable editing. */
#_sd_sdocs-file-info .fic-tag-hint {
  font-size: 10.5px;
  color: var(--fic-muted);
  font-style: italic;
  margin-left: 4px;
}
#_sd_sdocs-file-info .fic-tag-hint code {
  background: var(--md-pre-bg, rgba(0,0,0,0.04));
  border-radius: 3px;
  padding: 0 4px;
  font-family: var(--md-code-font);
  font-size: 10.5px;
  font-style: normal;
}

/* Inline composer: a single pill-shaped container that mirrors a chip's
   look (same height, same background, same border-radius). Inside sit
   the `#` prefix, the input (borderless, transparent, grows with the
   typed text via the HTML `size` attribute), and the tick/cancel
   icons. Modelled on the comment composer's pill. */
#_sd_sdocs-file-info .fic-tag-composer {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 0 4px 0 8px;
  background: var(--md-pre-bg, rgba(0,0,0,0.04));
  border: 1px solid var(--accent, #2563EB);
  border-radius: 999px;
  font-family: var(--md-code-font);
  font-size: 11.5px;
  line-height: 1.4;
  /* Match the chip's vertical rhythm: chip padding is 2px top/bottom +
     1.4 line-height + 1px border = ~22px. Set min-height so even with
     empty input the pill doesn't shrink below a chip. */
  min-height: 22px;
}
#_sd_sdocs-file-info .fic-tag-composer-hash {
  color: var(--text-3, var(--fic-muted));
  user-select: none;
}
#_sd_sdocs-file-info .fic-tag-input {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  font-family: inherit;
  font-size: inherit;
  color: var(--md-code-color);
  outline: none;
  min-width: 0;
  /* Width is set in JS to match the ruler's offsetWidth. */
}
/* Off-screen but laid out in the same font as the input so its
   offsetWidth is the exact rendered pixel width of the text. */
#_sd_sdocs-file-info .fic-tag-input-ruler {
  position: absolute;
  visibility: hidden;
  white-space: pre;
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  padding: 0;
}
#_sd_sdocs-file-info .fic-tag-input::placeholder {
  color: var(--text-3, var(--fic-muted));
  opacity: .7;
}
#_sd_sdocs-file-info .fic-tag-save,
#_sd_sdocs-file-info .fic-tag-cancel {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: var(--fic-muted);
  border-radius: 999px;
  transition: color .12s, background .12s;
}
/* Same SVG size as the chip × so the icons read as the same weight. */
#_sd_sdocs-file-info .fic-tag-save svg,
#_sd_sdocs-file-info .fic-tag-cancel svg {
  width: 10px;
  height: 10px;
}
#_sd_sdocs-file-info .fic-tag-save:hover {
  color: #2E7D32; /* same green as the recovery banner's tick */
  background: rgba(0,0,0,0.06);
}
#_sd_sdocs-file-info .fic-tag-cancel:hover {
  color: var(--md-p-color);
  background: rgba(0,0,0,0.06);
}

/* Suggested tags from the same project, shown beneath the composer. A
   ghost chip with a dashed outline, clicked to apply. Container is
   only inserted when there are items to show, so an :empty fallback
   isn't strictly needed - but keep it cheap in case that contract
   slips later. */
#_sd_sdocs-file-info .fic-tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  width: 100%;
  margin-top: 6px;
}
#_sd_sdocs-file-info .fic-tag-suggestions:empty {
  display: none;
  margin-top: 0;
}
#_sd_sdocs-file-info .fic-tag-suggestions-label {
  font-size: 10.5px;
  color: var(--text-3, var(--fic-muted));
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-right: 4px;
}
#_sd_sdocs-file-info .fic-tag-ghost {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: transparent;
  border: 1px dashed var(--md-copy-btn-border, rgba(0,0,0,0.18));
  border-radius: 999px;
  font-family: var(--md-code-font);
  font-size: 11.5px;
  color: var(--fic-muted);
  cursor: pointer;
  line-height: 1.4;
  transition: color .12s, border-color .12s, background .12s;
}
#_sd_sdocs-file-info .fic-tag-ghost:hover {
  color: var(--md-code-color, var(--md-p-color));
  border-color: var(--md-copy-btn-border);
  background: var(--md-copy-btn-hover, rgba(0,0,0,0.04));
}

/* Edits row: same layout as data rows (label, value, pill, RHS icon).
   Default icon colour matches the existing copy-button colour so the
   row reads as ambient state, not an alert. Only the lost state goes
   warm red to flag that typing isn't reaching disk. */
#_sd_sdocs-file-info .fic-row-bridge {
  cursor: default;
}
#_sd_sdocs-file-info .fic-bridge-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--fic-muted);
  transition: color .2s ease;
  flex-shrink: 0;
}
/* The screen-share-off glyph already reads as "disconnected" through its
   shape; layering a red on top is louder than the situation needs. Keep
   every state the same muted colour, let the icon shape do the work. */
/* Soft pulse on transient states so the user sees activity. */
#_sd_sdocs-file-info .fic-row-bridge[data-state="connecting"] .fic-bridge-icon,
#_sd_sdocs-file-info .fic-row-bridge[data-state="saving"]     .fic-bridge-icon {
  animation: fic-bridge-pulse 1.2s ease-in-out infinite;
}
@keyframes fic-bridge-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .45; }
}

/* Agent request row: shares the standard data-row layout. Only the
   label color shifts so the eye can find it. No background, no
   border, no padding changes. */
#_sd_sdocs-file-info .fic-row-request .fic-label {
  color: color-mix(in srgb, var(--accent, #4f46e5) 80%, var(--fic-muted));
}
#_sd_sdocs-file-info .fic-request-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#_sd_sdocs-file-info .fic-request-done {
  appearance: none;
  border: 0;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--accent, #4f46e5);
  color: #fff;
  font: 500 12px/1 var(--font-ui);
  cursor: pointer;
  flex-shrink: 0;
}
#_sd_sdocs-file-info .fic-request-done:hover { filter: brightness(1.08); }

#_sd_sdocs-file-info .fic-privacy-note {
  margin-top: 4px;
  font-size: 11px;
  color: var(--fic-muted);
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
#_sd_sdocs-file-info .fic-privacy-note[hidden] { display: none; }

/* Short URL row: fades + slides in after the Shorten button is clicked.
   Top-align label, value, and copy button so a URL that wraps to two lines
   reads as a deliberate block, not a ragged baseline-aligned row. */
#_sd_sdocs-file-info .fic-row-short {
  align-items: flex-start;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .3s cubic-bezier(.4,0,.2,1), transform .3s cubic-bezier(.4,0,.2,1);
}
#_sd_sdocs-file-info .fic-row-short.fic-row-short-enter {
  opacity: 0;
  transform: translateY(-4px);
}
/* The short URL is one long opaque string. break-all fills every line edge
   to edge so a wrap looks like a deliberate text block, instead of the ragged
   short first line that break-word leaves when it snaps at a hyphen. */
#_sd_sdocs-file-info .fic-row-short .fic-value {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, monospace);
  font-size: 12px;
  word-break: break-all;
  overflow-wrap: normal;
  line-height: 1.6;
}

/* Shorten action row: button + inline error */
#_sd_sdocs-file-info .fic-row-shorten {
  cursor: default;
}
#_sd_sdocs-file-info .fic-row-shorten:hover .fic-copy { color: var(--fic-muted); }
#_sd_sdocs-file-info .fic-shorten-button {
  background: transparent;
  border: none;
  color: var(--md-p-color);
  font: inherit;
  padding: 0;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--md-p-color) 45%, transparent);
  transition: text-decoration-color .12s, text-decoration-style .12s;
}
#_sd_sdocs-file-info .fic-shorten-button:hover:not(:disabled) {
  text-decoration-style: solid;
  text-decoration-color: var(--md-p-color);
}
#_sd_sdocs-file-info .fic-shorten-button:disabled {
  cursor: default;
  opacity: 0.6;
}
#_sd_sdocs-file-info .fic-shorten-button.fic-shorten-loading {
  opacity: 0.7;
}
#_sd_sdocs-file-info .fic-shorten-error {
  font-size: 11px;
  color: #b42318;
}
#_sd_sdocs-file-info .fic-shorten-error[hidden] { display: none; }

/* Intro row: shown before the short URL is generated */
#_sd_sdocs-file-info .fic-row-short-intro {
  cursor: default;
}
#_sd_sdocs-file-info .fic-short-intro-text {
  flex: 1;
  min-width: 0;
  color: var(--fic-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
#_sd_sdocs-file-info .fic-short-intro-learn {
  color: var(--fic-muted);
  text-decoration: underline;
  transition: color .12s;
}
#_sd_sdocs-file-info .fic-short-intro-learn:hover {
  color: var(--md-p-color);
}

/* ── Interactive form blocks (```form) ─────────────────────────
   Rendered after marked+DOMPurify by sdocs-forms.js. We replace the
   <pre><code class="language-form"> with a real <form> built via
   createElement. Style is calm and document-shaped, not "web form" — 
   the goal is to feel like the markdown is still in charge. */
.sdoc-form-host { margin: 1em 0; }
.sdoc-form {
  display: block;
  border: 1px solid var(--md-block-border, #e6e6e6);
  background: var(--md-block-bg, transparent);
  border-radius: 6px;
  padding: 14px 16px;
}
.sdoc-form-field { margin: 0 0 14px; }
.sdoc-form-field:last-of-type { margin-bottom: 0; }
.sdoc-form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--md-color, inherit);
  font-size: 0.95em;
}
.sdoc-form-required { color: #c11; font-weight: 600; margin-left: 2px; }
.sdoc-form-help {
  margin-top: 3px;
  font-size: 0.82em;
  color: var(--text-2, #777);
  line-height: 1.4;
}
.sdoc-form-input,
.sdoc-form-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 9px;
  border: 1px solid var(--md-block-border, #d6d6d6);
  border-radius: 4px;
  font: inherit;
  font-size: 0.95em;
  background: var(--bg-input, #fff);
  color: var(--md-color, inherit);
}
.sdoc-form-textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
.sdoc-form-input:focus,
.sdoc-form-textarea:focus {
  outline: 2px solid var(--accent, #4f46e5);
  outline-offset: 0;
  border-color: transparent;
}
.sdoc-form-radio-group,
.sdoc-form-checkbox-group { display: flex; flex-direction: column; gap: 4px; }
.sdoc-form-radio-line,
.sdoc-form-checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.95em;
  padding: 2px 0;
}
.sdoc-form-radio-line input[type="radio"],
.sdoc-form-checkbox-line input[type="checkbox"] { margin: 0; }
.sdoc-form-select {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 9px;
  border: 1px solid var(--md-block-border, #d6d6d6);
  border-radius: 4px;
  font: inherit;
  font-size: 0.95em;
  background: var(--bg-input, #fff);
  color: var(--md-color, inherit);
}
.sdoc-form-select:focus {
  outline: 2px solid var(--accent, #4f46e5);
  outline-offset: 0;
  border-color: transparent;
}
.sdoc-form-input-number,
.sdoc-form-input-date {
  /* Numbers and dates sit narrower than free-text inputs by default
     because their content is bounded; the browser still respects width
     100% if a longer placeholder forces it. */
  width: auto;
  min-width: 140px;
}
.sdoc-form-buttons {
  display: flex;
  gap: 14px;
  margin-top: 16px;
  flex-wrap: wrap;
  align-items: flex-start;
}
.sdoc-form-buttons-inline {
  /* Inline submits sit tighter against the field they belong to. */
  margin-top: 8px;
  margin-bottom: 4px;
}
.sdoc-form-button-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  /* Stops a long hint line from breaking the row layout. */
  max-width: 360px;
}
.sdoc-form-button-hint {
  font-size: 0.78em;
  color: var(--md-color-muted, #777);
  line-height: 1.35;
  /* Slight indent so the hint visually sits under its button. */
  padding-left: 2px;
}
.sdoc-form-button-saved {
  font-size: 0.78em;
  color: #2e9b5e;
  font-style: italic;
  line-height: 1.35;
  padding-left: 2px;
}
.sdoc-form-submit.is-sending {
  opacity: 0.75;
  cursor: progress;
}
.sdoc-form-submit.is-sent {
  background: #2e9b5e;
  border-color: #2e9b5e;
}
.sdoc-form-submit.is-locked,
.sdoc-form-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}
.sdoc-form-locked .sdoc-form-button-hint {
  opacity: 0.55;
}
.sdoc-form-locked .sdoc-form-label {
  opacity: 0.7;
}
/* Browsers don't visibly disable input value text by default (Chromium
   keeps it near-black), so we explicitly mute color + cursor for every
   text-bearing control inside a locked form. */
.sdoc-form-locked .sdoc-form-input,
.sdoc-form-locked .sdoc-form-textarea,
.sdoc-form-locked .sdoc-form-select {
  color: var(--md-color-muted, #888);
  background: rgba(0, 0, 0, 0.03);
  border-color: var(--md-block-border, #d6d6d6);
  cursor: not-allowed;
}
/* Native radio / checkbox dots don't take `color`. Opacity is the only
   reliable way to read them as inactive across themes. */
.sdoc-form-locked .sdoc-form-radio-line,
.sdoc-form-locked .sdoc-form-checkbox-line {
  cursor: not-allowed;
  opacity: 0.55;
}
.sdoc-form-ended-note {
  margin-top: 14px;
  padding: 6px 10px;
  font-size: 0.85em;
  color: var(--md-color-muted, #777);
  border-left: 2px solid var(--md-block-border, #d6d6d6);
  background: var(--md-block-bg-soft, transparent);
}
.sdoc-form-submit {
  appearance: none;
  border: 1px solid var(--accent, #4f46e5);
  background: var(--accent, #4f46e5);
  color: #fff;
  padding: 7px 14px;
  border-radius: 5px;
  font: 500 13px/1 var(--font-ui);
  cursor: pointer;
  transition: filter .15s ease;
}
.sdoc-form-submit:hover { filter: brightness(1.08); }
.sdoc-form-submit:active { filter: brightness(.95); }
.sdoc-form-submit[data-final="true"] {
  /* Final submit gets a slightly bolder fill so the "this ends it"
     intent is visible at a glance. */
  font-weight: 600;
}
.sdoc-form-error-text {
  margin-top: 4px;
  color: #c11;
  font-size: 0.82em;
}
.sdoc-form-field-invalid .sdoc-form-input,
.sdoc-form-field-invalid .sdoc-form-textarea,
.sdoc-form-field-invalid .sdoc-form-select { border-color: #c11; }
.sdoc-form-error {
  border: 1px solid #f0c0c0;
  background: #fff7f7;
  padding: 8px 10px;
  border-radius: 5px;
  margin: 1em 0;
}
.sdoc-form-error-label {
  font-size: 0.85em;
  color: #b22;
  margin-bottom: 4px;
}
