/* ========================================
   @neutralaiz/markdown-core — Canonical Styles
   Single source of truth for markdown rendering.
   Used by both AI Sidebar and Zammad plugin.
   ======================================== */

/* ========================================
   Root fallback — for components like tooltips + selection-toolbar
   that mount into document.body (outside .nmd-dark/.nmd-light scope).
   Defaults to dark theme values so mounted UI never renders transparent.
   ======================================== */
:root {
  --nmd-text: #c8c8d0;
  --nmd-text-secondary: #a0a0a0;
  --nmd-text-muted: #6c6c8a;
  --nmd-bg: #0f0f23;
  --nmd-bg-secondary: #16213e;
  --nmd-bg-tertiary: #0a0a1a;
  --nmd-bg-hover: #252545;
  --nmd-border: #2d2d5a;
  --nmd-accent: #6366f1;
  --nmd-accent-hover: #818cf8;
  --nmd-mono: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

/* ========================================
   Dark Theme (default)
   ======================================== */
.nmd-dark {
  --nmd-text: #c8c8d0;
  --nmd-text-secondary: #a0a0a0;
  --nmd-text-muted: #6c6c8a;
  --nmd-bg: #0f0f23;
  --nmd-bg-secondary: #16213e;
  --nmd-bg-tertiary: #0a0a1a;
  --nmd-bg-hover: #252545;
  --nmd-border: #2d2d5a;
  --nmd-accent: #6366f1;
  --nmd-accent-hover: #818cf8;
  --nmd-mono: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

/* ========================================
   Light Theme
   ======================================== */
.nmd-light {
  --nmd-text: #1a1a1a;
  --nmd-text-secondary: #555555;
  --nmd-text-muted: #888888;
  --nmd-bg: #ffffff;
  --nmd-bg-secondary: #f5f7f9;
  --nmd-bg-tertiary: #f0f2f5;
  --nmd-bg-hover: #e8edf2;
  --nmd-border: #d1d5db;
  --nmd-accent: #4f46e5;
  --nmd-accent-hover: #6366f1;
  --nmd-mono: 'SF Mono', Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
}

/* ========================================
   Base Container
   ======================================== */
.nmd-content {
  font-size: 13px;
  line-height: 1.6;
  color: var(--nmd-text);
  word-wrap: break-word;
}

/* ========================================
   Headers
   Top margin uses em so the gap scales with the header's own font-size —
   larger heading = larger gap, smaller heading = smaller gap, automatically.
   ======================================== */
.nmd-content h1 {
  font-size: 1.4em;
  font-weight: 600;
  margin: 1.5em 0 0.5em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--nmd-border);
  color: var(--nmd-text);
}

.nmd-content h2 {
  font-size: 1.25em;
  font-weight: 600;
  margin: 1.3em 0 0.4em;
  color: var(--nmd-text);
}

.nmd-content h3 {
  font-size: 1.1em;
  font-weight: 600;
  margin: 1.1em 0 0.3em;
  color: var(--nmd-text);
}

.nmd-content h4,
.nmd-content h5,
.nmd-content h6 {
  font-size: 1em;
  font-weight: 600;
  margin: 1em 0 0.25em;
  color: var(--nmd-text-secondary);
}

/* ========================================
   Text
   ======================================== */
.nmd-content p { margin: 0.5em 0; }
.nmd-content strong, .nmd-content b { font-weight: 600; color: var(--nmd-text); }
.nmd-content em { font-style: italic; }
.nmd-content del { text-decoration: line-through; opacity: 0.7; }

/* ========================================
   Links
   ======================================== */
.nmd-content a { color: var(--nmd-accent); text-decoration: none; transition: color 0.15s ease; }
.nmd-content a:hover { color: var(--nmd-accent-hover); text-decoration: underline; }

/* ========================================
   Lists
   ======================================== */
.nmd-content ul,
.nmd-content ol {
  margin: 0.5em 0;
  padding-left: 0;
  list-style: none;
}

.nmd-content li {
  margin: 0.25em 0;
  padding-left: 1.5em;
  position: relative;
  color: var(--nmd-text);
}

.nmd-content ul ul,
.nmd-content ul ol,
.nmd-content ol ul,
.nmd-content ol ol {
  margin: 0.25em 0;
  padding-left: 1em;
}

.nmd-content ul > li::before {
  content: "\2022";
  position: absolute;
  left: 0.5em;
  color: var(--nmd-accent);
}

.nmd-content ul ul > li::before { content: "\25E6"; }
.nmd-content ul ul ul > li::before { content: "\25AA"; }

/* Ordered list — native numbering so <ol start="N"> works and
   merged consecutive <ol> elements number correctly. */
.nmd-content ol {
  list-style: decimal;
  padding-left: 1.5em;
}
.nmd-content ol > li {
  padding-left: 0.3em;
}
.nmd-content ol > li::before {
  content: none;
}
.nmd-content ol > li::marker {
  color: var(--nmd-accent);
  font-weight: 500;
}

/* Task lists */
.nmd-content input[type="checkbox"] {
  margin-right: 6px;
  accent-color: var(--nmd-accent);
}
.nmd-content li:has(> input[type="checkbox"])::before { content: none; }

/* ========================================
   Tables
   ======================================== */
.nmd-content table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  margin: 1em 0;
  border: 1px solid var(--nmd-border);
  overflow: hidden;
}

.nmd-content th,
.nmd-content td {
  border: 1px solid var(--nmd-border);
  padding: 6px 10px;
  text-align: left;
  color: var(--nmd-text);
}

.nmd-content th {
  background: var(--nmd-bg-secondary);
  font-weight: 600;
  color: var(--nmd-text);
}

.nmd-content tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
.nmd-content tr:hover { background: var(--nmd-bg-hover); }

/* Light theme: different alternating rows */
.nmd-light.nmd-content tr:nth-child(even) { background: rgba(0, 0, 0, 0.02); }

/* ========================================
   Code
   ======================================== */
.nmd-content code {
  background: var(--nmd-bg-hover);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--nmd-mono);
  font-size: 0.9em;
  color: var(--nmd-accent);
}

.nmd-content pre {
  background: var(--nmd-bg-tertiary);
  border: 1px solid var(--nmd-border);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  margin: 1em 0;
}

.nmd-content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-family: var(--nmd-mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--nmd-text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Code block wrapper with language label + copy button */
.nmd-code {
  position: relative;
  margin: 1em 0;
}

.nmd-code pre {
  margin: 0;
  border-radius: 0 0 6px 6px;
}

.nmd-code__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--nmd-bg-secondary);
  border: 1px solid var(--nmd-border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 4px 10px;
  min-height: 28px;
}

.nmd-code__lang {
  font-family: var(--nmd-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--nmd-text-muted);
  text-transform: lowercase;
}

.nmd-code__copy {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--nmd-border);
  border-radius: 4px;
  color: var(--nmd-text-muted);
  font-size: 11px;
  font-family: inherit;
  padding: 2px 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nmd-code__copy:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--nmd-text);
}

.nmd-light .nmd-code__copy {
  background: rgba(0, 0, 0, 0.04);
}
.nmd-light .nmd-code__copy:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* Parse-error underline — wavy red decoration on the failing codepoint.
   Placed by the non-interactive code renderer when tryPretty() returns an
   error for JSON/XML. native title="" supplies the tooltip; no JS. */
.nmd-code__error-token {
  text-decoration: underline wavy #ef4444;
  text-decoration-skip-ink: none;
  cursor: help;
  border-radius: 2px;
  padding: 0 1px;
}
.nmd-code__error-token:hover {
  background: rgba(239, 68, 68, 0.18);
}
.nmd-light .nmd-code__error-token {
  text-decoration-color: #dc2626;
}
.nmd-light .nmd-code__error-token:hover {
  background: rgba(220, 38, 38, 0.12);
}

/* ========================================
   Syntax Highlighting — One Dark
   ======================================== */
.nmd-dark .hljs-comment, .nmd-dark .hljs-quote { color: var(--nmd-text-muted); font-style: italic; }
.nmd-dark .hljs-keyword, .nmd-dark .hljs-selector-tag { color: #c678dd; }
.nmd-dark .hljs-string, .nmd-dark .hljs-attribute, .nmd-dark .hljs-addition { color: #98c379; }
.nmd-dark .hljs-number, .nmd-dark .hljs-literal { color: #d19a66; }
.nmd-dark .hljs-function, .nmd-dark .hljs-title { color: #61afef; }
.nmd-dark .hljs-variable, .nmd-dark .hljs-template-variable { color: #e06c75; }
.nmd-dark .hljs-type, .nmd-dark .hljs-class .hljs-title { color: #e5c07b; }
.nmd-dark .hljs-built_in { color: #56b6c2; }
.nmd-dark .hljs-attr { color: #e06c75; }
.nmd-dark .hljs-punctuation { color: #abb2bf; }
.nmd-dark .hljs-meta { color: #61afef; }
.nmd-dark .hljs-symbol { color: #56b6c2; }
.nmd-dark .hljs-selector-class { color: #e5c07b; }
.nmd-dark .hljs-subst { color: #e06c75; }

/* Syntax Highlighting — One Light */
.nmd-light .hljs-comment, .nmd-light .hljs-quote { color: var(--nmd-text-muted); font-style: italic; }
.nmd-light .hljs-keyword, .nmd-light .hljs-selector-tag { color: #a626a4; }
.nmd-light .hljs-string, .nmd-light .hljs-attribute, .nmd-light .hljs-addition { color: #50a14f; }
.nmd-light .hljs-number, .nmd-light .hljs-literal { color: #986801; }
.nmd-light .hljs-function, .nmd-light .hljs-title { color: #4078f2; }
.nmd-light .hljs-variable, .nmd-light .hljs-template-variable { color: #e45649; }
.nmd-light .hljs-type, .nmd-light .hljs-class .hljs-title { color: #c18401; }
.nmd-light .hljs-built_in { color: #0184bc; }

/* ========================================
   Blockquotes
   ======================================== */
.nmd-content blockquote {
  border-left: 4px solid var(--nmd-accent);
  margin: 1em 0;
  padding: 6px 12px;
  background: rgba(99, 102, 241, 0.08);
  color: var(--nmd-text-secondary);
  border-radius: 0 4px 4px 0;
}

.nmd-content blockquote p { margin: 0; }
.nmd-content blockquote blockquote { margin: 0.5em 0; }

/* ========================================
   Images
   ======================================== */
.nmd-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 1em 0;
  display: block;
}

/* ========================================
   Horizontal Rule
   ======================================== */
.nmd-content hr {
  border: none;
  border-top: 1px solid var(--nmd-border);
  margin: 1.5em 0;
}

/* ========================================
   Margins
   ======================================== */
.nmd-content > *:first-child { margin-top: 0; }
.nmd-content > *:last-child { margin-bottom: 0; }

/* ========================================
   AI Article Branded Container (Zammad)
   ======================================== */
.nmd-ai-article {
  background: var(--nmd-bg);
  border: 1px solid var(--nmd-border);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 4px 0;
}

.nmd-ai-article__header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--nmd-border);
}

.nmd-ai-article__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--nmd-accent);
}

.nmd-ai-article__icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--nmd-accent);
  flex-shrink: 0;
}

/* ========================================
   Action Buttons
   ======================================== */
.nmd-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--nmd-border);
}

.nmd-actions__btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: #c4b5fd;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.nmd-actions__btn:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(129, 140, 248, 0.5);
  color: #ddd6fe;
}

.nmd-actions__btn:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; }
.nmd-actions__btn--loading { opacity: 0.7; cursor: wait; }
.nmd-actions__btn--sent { color: #86efac; background: rgba(34, 197, 94, 0.15); border-color: rgba(34, 197, 94, 0.3); cursor: default; }
.nmd-actions__btn--error { color: #fca5a5; background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.3); cursor: pointer; }

/* Light theme action buttons */
.nmd-light .nmd-actions__btn { color: #4f46e5; background: rgba(79, 70, 229, 0.08); border-color: rgba(79, 70, 229, 0.2); }
.nmd-light .nmd-actions__btn:hover { background: rgba(79, 70, 229, 0.15); border-color: rgba(79, 70, 229, 0.4); }

/* ========================================
   :::details Collapsible Sections
   Emitted by details-extension.js — <details class="nmd-details"> etc.
   ======================================== */
.nmd-content .nmd-details {
  margin: 0.75em 0;
  border: 1px solid var(--nmd-border);
  border-radius: 6px;
  background: var(--nmd-bg-secondary);
  overflow: hidden;
}

.nmd-content .nmd-details[open] {
  background: var(--nmd-bg);
}

.nmd-content .nmd-details__summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 0.95em;
  font-weight: 600;
  color: var(--nmd-text);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background 0.15s ease;
}

.nmd-content .nmd-details__summary::-webkit-details-marker { display: none; }
.nmd-content .nmd-details__summary:hover { background: var(--nmd-bg-hover); }
.nmd-content .nmd-details__summary:focus-visible {
  outline: 2px solid var(--nmd-accent);
  outline-offset: -2px;
}

/* Chevron — rotates when the details is open. */
.nmd-content .nmd-details__summary::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 4px;
  border-left: 5px solid var(--nmd-text-secondary);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s ease;
}
.nmd-content .nmd-details[open] > .nmd-details__summary::before {
  transform: rotate(90deg);
}

.nmd-content .nmd-details__body {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--nmd-border);
  color: var(--nmd-text);
}

.nmd-content .nmd-details__body > *:first-child { margin-top: 0; }
.nmd-content .nmd-details__body > *:last-child { margin-bottom: 0; }

/* Nested details — slightly tightened and with a thinner indent. */
.nmd-content .nmd-details .nmd-details {
  margin: 0.5em 0;
}

/* ========================================
   Entity Pills
   Emitted by pills.js (authored) and auto-detect.js (inline-detected).
   Match the existing accent palette; per-kind color-key on hover/focus.
   ======================================== */
.nmd-content .nmd-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px 1px 6px;
  font-family: inherit;
  font-size: 0.9em;
  font-weight: 500;
  line-height: 1.4;
  color: var(--nmd-text);
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  vertical-align: baseline;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.nmd-content .nmd-pill:hover,
.nmd-content .nmd-pill:focus-visible {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(129, 140, 248, 0.6);
  color: var(--nmd-accent-hover);
  outline: none;
}

.nmd-content .nmd-pill:focus-visible {
  box-shadow: 0 0 0 2px var(--nmd-accent);
}

.nmd-content .nmd-pill[aria-expanded="true"] {
  background: rgba(99, 102, 241, 0.3);
  border-color: var(--nmd-accent);
}

.nmd-content .nmd-pill__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: var(--nmd-accent);
}

.nmd-content .nmd-pill__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Product pill thumbnail — replaces the SVG icon slot. Square tile with
   object-fit: cover so wide/tall product shots crop cleanly. Background
   covers the slot before the img loads (or if the src 404s). */
.nmd-content .nmd-pill__thumb {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
  display: inline-block;
  vertical-align: middle;
}

.nmd-light .nmd-pill__thumb {
  background: rgba(0, 0, 0, 0.04);
}

.nmd-content .nmd-pill__label {
  display: inline-block;
  max-width: 32ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* Per-kind color tinting — subtle, distinguishable without being loud. */
.nmd-content .nmd-pill--product {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
}
.nmd-content .nmd-pill--product:hover,
.nmd-content .nmd-pill--product:focus-visible {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(96, 165, 250, 0.6);
  color: #60a5fa;
}
.nmd-content .nmd-pill--product .nmd-pill__icon { color: #60a5fa; }

.nmd-content .nmd-pill--customer {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
}
.nmd-content .nmd-pill--customer:hover,
.nmd-content .nmd-pill--customer:focus-visible {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(134, 239, 172, 0.6);
  color: #86efac;
}
.nmd-content .nmd-pill--customer .nmd-pill__icon { color: #86efac; }

.nmd-content .nmd-pill--contact {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
}
.nmd-content .nmd-pill--contact:hover,
.nmd-content .nmd-pill--contact:focus-visible {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(134, 239, 172, 0.6);
  color: #86efac;
}
.nmd-content .nmd-pill--contact .nmd-pill__icon { color: #86efac; }

.nmd-content .nmd-pill--order {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
}
.nmd-content .nmd-pill--order:hover,
.nmd-content .nmd-pill--order:focus-visible {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(252, 211, 77, 0.6);
  color: #fcd34d;
}
.nmd-content .nmd-pill--order .nmd-pill__icon { color: #fcd34d; }

.nmd-content .nmd-pill--quote {
  background: rgba(168, 85, 247, 0.1);
  border-color: rgba(168, 85, 247, 0.3);
}
.nmd-content .nmd-pill--quote:hover,
.nmd-content .nmd-pill--quote:focus-visible {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(216, 180, 254, 0.6);
  color: #d8b4fe;
}
.nmd-content .nmd-pill--quote .nmd-pill__icon { color: #d8b4fe; }

.nmd-content .nmd-pill--branch {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.3);
}
.nmd-content .nmd-pill--branch:hover,
.nmd-content .nmd-pill--branch:focus-visible {
  background: rgba(6, 182, 212, 0.2);
  border-color: rgba(103, 232, 249, 0.6);
  color: #67e8f9;
}
.nmd-content .nmd-pill--branch .nmd-pill__icon { color: #67e8f9; }

.nmd-content .nmd-pill--vendor {
  background: rgba(217, 70, 239, 0.1);
  border-color: rgba(217, 70, 239, 0.3);
}
.nmd-content .nmd-pill--vendor:hover,
.nmd-content .nmd-pill--vendor:focus-visible {
  background: rgba(217, 70, 239, 0.2);
  border-color: rgba(240, 171, 252, 0.6);
  color: #f0abfc;
}
.nmd-content .nmd-pill--vendor .nmd-pill__icon { color: #f0abfc; }

.nmd-content .nmd-pill--channel {
  background: rgba(174, 182, 212, 0.1);
  border-color: rgba(174, 182, 212, 0.3);
}
.nmd-content .nmd-pill--channel:hover,
.nmd-content .nmd-pill--channel:focus-visible {
  background: rgba(174, 182, 212, 0.2);
  border-color: rgba(174, 182, 212, 0.6);
  color: #aeb6d4;
}
.nmd-content .nmd-pill--channel .nmd-pill__icon { color: #aeb6d4; }

/* Light theme pill tweaks — higher-contrast backgrounds. */
.nmd-light .nmd-pill { background: rgba(79, 70, 229, 0.06); border-color: rgba(79, 70, 229, 0.2); }
.nmd-light .nmd-pill:hover,
.nmd-light .nmd-pill:focus-visible { background: rgba(79, 70, 229, 0.15); border-color: rgba(79, 70, 229, 0.4); }

.nmd-light .nmd-pill--product { background: rgba(59, 130, 246, 0.08); border-color: rgba(59, 130, 246, 0.25); }
.nmd-light .nmd-pill--customer { background: rgba(22, 163, 74, 0.08); border-color: rgba(22, 163, 74, 0.25); }
.nmd-light .nmd-pill--contact { background: rgba(21, 128, 61, 0.08); border-color: rgba(21, 128, 61, 0.25); }
.nmd-light .nmd-pill--order { background: rgba(217, 119, 6, 0.08); border-color: rgba(217, 119, 6, 0.25); }
.nmd-light .nmd-pill--quote { background: rgba(147, 51, 234, 0.08); border-color: rgba(147, 51, 234, 0.25); }
.nmd-light .nmd-pill--branch { background: rgba(8, 145, 178, 0.08); border-color: rgba(8, 145, 178, 0.25); }
.nmd-light .nmd-pill--vendor { background: rgba(162, 28, 175, 0.08); border-color: rgba(162, 28, 175, 0.25); }
.nmd-light .nmd-pill--channel { background: rgba(90, 98, 133, 0.08); border-color: rgba(90, 98, 133, 0.25); }

/* ========================================
   Tooltip (pill hover/click preview card)
   Positioning handled by tooltip-controller.js (owned by A2).
   ======================================== */
.nmd-tooltip {
  position: absolute;
  z-index: 10000;
  max-width: 400px;
  min-width: 220px;
  padding: 12px 14px;
  background: var(--nmd-bg);
  border: 1px solid var(--nmd-border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 4px 10px rgba(0, 0, 0, 0.2);
  color: var(--nmd-text);
  font-size: 0.9em;
  line-height: 1.45;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.nmd-tooltip[data-nmd-open="true"],
.nmd-tooltip[data-state="loading"],
.nmd-tooltip[data-state="ready"],
.nmd-tooltip[data-state="error"] {
  opacity: 1;
  transform: translateY(0);
}

.nmd-tooltip__loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--nmd-text-secondary);
  font-size: 0.9em;
  padding: 4px 0;
}

.nmd-tooltip__loading::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--nmd-border);
  border-top-color: var(--nmd-accent);
  border-radius: 50%;
  animation: nmd-tooltip-spin 0.6s linear infinite;
}

@keyframes nmd-tooltip-spin {
  to { transform: rotate(360deg); }
}

.nmd-tooltip__error {
  color: #fca5a5;
  font-size: 0.9em;
  padding: 4px 0;
}

.nmd-light .nmd-tooltip__error { color: #b91c1c; }

.nmd-tooltip__header {
  font-weight: 600;
  font-size: 1em;
  margin-bottom: 4px;
  color: var(--nmd-text);
}

.nmd-tooltip__meta {
  font-size: 0.85em;
  color: var(--nmd-text-secondary);
  margin-bottom: 6px;
}

.nmd-tooltip__body {
  font-size: 0.9em;
  color: var(--nmd-text);
}

.nmd-tooltip__body > *:first-child { margin-top: 0; }
.nmd-tooltip__body > *:last-child { margin-bottom: 0; }

/* ========================================
   Selection Toolbar (floating "Ask Anderra" button)
   Positioning handled by selection-context.js consumer (Zammad plugin /
   sidebar). JS toggles visibility and computes top/left.
   ======================================== */
.nmd-selection-toolbar {
  position: absolute;
  z-index: 10001;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: var(--nmd-bg);
  border: 1px solid var(--nmd-border);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.18);
  font-size: 12px;
  pointer-events: auto;
}

.nmd-selection-toolbar[data-nmd-visible="true"] {
  display: inline-flex;
}

.nmd-selection-toolbar__btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--nmd-accent-hover);
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.nmd-selection-toolbar__btn:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(129, 140, 248, 0.55);
}

.nmd-selection-toolbar__btn:focus-visible {
  outline: 2px solid var(--nmd-accent);
  outline-offset: 2px;
}

.nmd-selection-toolbar__preview {
  max-width: 260px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--nmd-text-secondary);
  background: var(--nmd-bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nmd-light .nmd-selection-toolbar__btn {
  color: #4f46e5;
  background: rgba(79, 70, 229, 0.1);
  border-color: rgba(79, 70, 229, 0.3);
}
