/* Realtime editing of Markdown fields (ADR-0054 stage 2, ADR-0057 phase 4): band "… bearbeitet dieses
   Feld", remote cursors and selections in the colour of the figure, source mode with live preview and the
   kept own draft. Owned by the "collab" strand. */
.ui-markdown-editor__collab {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.ui-markdown-editor__collab-band {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  color: var(--color-ink);
  background: var(--color-surface-soft);
  border: 1px solid var(--color-line);
  border-left: 3px solid var(--color-brand);
  border-radius: var(--radius-sm);
}

.ui-markdown-editor__collab-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ui-markdown-editor__collab-status {
  font-size: 0.875rem;
  color: var(--color-ink-soft);
}

.ui-markdown-editor__collab-status:empty {
  display: none;
}

/* Shared session: Markdown source with live preview below; the visual mode is locked. */
.ui-markdown-editor.is-collaborating .ui-markdown-editor__form {
  position: relative;
}

.ui-markdown-editor.is-collaborating .ui-markdown-editor__preview {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--color-line);
}

.ui-markdown-editor.is-collaborating .ui-markdown-editor__preview::before {
  content: "Live-Vorschau";
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  color: var(--color-ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ui-markdown-editor__mode[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Mirror layer over the textarea: transparent text, painted ranges of the others. */
.presence-collab-cursors {
  position: absolute;
  overflow: hidden;
  color: transparent;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  pointer-events: none;
  border-style: solid;
  border-color: transparent;
}

.presence-collab-cursors__range {
  position: relative;
  background: color-mix(in srgb, var(--collab-color, #46f5ad) 28%, transparent);
  border-radius: 2px;
}

.presence-collab-cursors__caret {
  position: relative;
  display: inline-block;
  width: 0;
  height: 1.2em;
  margin: 0 -1px;
  vertical-align: text-bottom;
  border-left: 2px solid var(--collab-color, #46f5ad);
}

.presence-collab-cursors__name {
  position: absolute;
  bottom: 100%;
  left: -2px;
  padding: 0 0.25rem;
  font-size: 0.6875rem;
  line-height: 1.4;
  color: #10201b;
  white-space: nowrap;
  background: var(--collab-color, #46f5ad);
  border-radius: 3px 3px 3px 0;
}

.presence-collab-draft {
  display: grid;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
}

.presence-collab-draft > summary {
  font-weight: 600;
  cursor: pointer;
}

.presence-collab-draft > button {
  justify-self: start;
}
