.markdown-editor .markdown-editor-content {
  outline: none;
}

/* Inherit semantic foreground so the editor renders correctly in both
   light + dark themes (and under any active preset). Without this the
   browser falls back to UA black on a token-driven background. */
.markdown-editor .tiptap,
.markdown-editor .ProseMirror {
  color: var(--color-foreground, var(--foreground));
}

.markdown-editor .tiptap a,
.markdown-editor .ProseMirror a {
  color: var(--color-primary, var(--primary));
  text-decoration: underline;
}

.markdown-editor .tiptap h1 {
  font-size: 1.5em;
  font-weight: 700;
  margin: 0.5em 0 0.25em;
  line-height: 1.3;
}

.markdown-editor .tiptap h2 {
  font-size: 1.25em;
  font-weight: 600;
  margin: 0.5em 0 0.25em;
  line-height: 1.3;
}

.markdown-editor .tiptap h3 {
  font-size: 1.1em;
  font-weight: 600;
  margin: 0.4em 0 0.2em;
  line-height: 1.3;
}

.markdown-editor .tiptap p {
  margin: 0.25em 0;
}

.markdown-editor .tiptap ul,
.markdown-editor .tiptap ol {
  padding-left: 1.5em;
  margin: 0.25em 0;
}

.markdown-editor .tiptap ul {
  list-style: disc;
}

.markdown-editor .tiptap ol {
  list-style: decimal;
}

.markdown-editor .tiptap li {
  margin: 0.1em 0;
}

.markdown-editor .tiptap blockquote {
  border-left: 3px solid var(--color-border, var(--border));
  padding-left: 1em;
  margin: 0.5em 0;
  opacity: 0.8;
}

.markdown-editor .tiptap hr {
  border: none;
  border-top: 1px solid var(--color-border, var(--border));
  margin: 0.75em 0;
}

.markdown-editor .tiptap code {
  background: var(--color-muted, var(--muted));
  color: var(--color-muted-foreground, var(--muted-foreground));
  padding: 0.15em 0.3em;
  border-radius: 0.25em;
  font-size: 0.9em;
  font-family: monospace;
}

.markdown-editor .tiptap strong {
  font-weight: 700;
}

.markdown-editor .tiptap em {
  font-style: italic;
}

.markdown-editor .tiptap s {
  text-decoration: line-through;
}

.markdown-editor .tiptap p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  pointer-events: none;
  height: 0;
  opacity: 0.4;
}

/* Focus ring */
.markdown-editor:focus-within {
  border-color: var(--color-ring, var(--ring));
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--color-ring, var(--ring)) 30%, transparent);
}

/* Embedded mode — the host surface (e.g. chat composer) draws the
   frame, so the editor must not paint its own border or focus ring. */
.markdown-editor--unstyled,
.markdown-editor--unstyled:focus-within {
  border: none;
  background: transparent;
  box-shadow: none;
}

/* Mention inline chip */
.markdown-mention {
  background: var(--color-primary, var(--primary));
  color: var(--color-primary-foreground, #fff);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-weight: 500;
  cursor: default;
}

/* Mention dropdown */
.markdown-mention-list {
  background: var(--color-popover, var(--popover));
  color: var(--color-popover-foreground, var(--popover-foreground));
  border: 1px solid var(--color-border, var(--border));
  border-radius: 8px;
  padding: 4px;
  min-width: 220px;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.markdown-mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  transition: background 0.1s;
}

.markdown-mention-item:hover,
.markdown-mention-item.selected {
  background: var(--color-muted, var(--muted));
}

.markdown-mention-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.markdown-mention-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.markdown-mention-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.markdown-mention-desc {
  font-size: 11px;
  opacity: 0.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Toolbar buttons */
.markdown-toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: none;
  background: transparent;
  /* Explicit semantic colour — without it the icon inherits the host's
     default text colour (UA black on a dark editor surface) and the
     toolbar is invisible. */
  color: var(--foreground);
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s, background 0.15s;
}

.markdown-toolbar-btn:hover {
  opacity: 1;
  background: var(--color-muted, var(--muted));
}

.markdown-toolbar-btn.active {
  opacity: 1;
  background: var(--color-muted, var(--muted));
}
