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

/* ─────────────────────────────────────────────────────────────────────
 * Typography — Notion-inspired: comfy line-height, generous heading
 * scale, restrained spacing. Calibrated so the chat composer (compact,
 * single-paragraph) and the document-preview editor (long-form, with
 * many headings) both feel right without a variant prop.
 *
 * Inherit semantic foreground so the editor renders correctly in both
 * light + dark themes (and under any active preset).
 * ───────────────────────────────────────────────────────────────────── */
.markdown-editor .tiptap,
.markdown-editor .ProseMirror {
  color: var(--color-foreground, var(--foreground));
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

.markdown-editor .tiptap a:hover,
.markdown-editor .ProseMirror a:hover {
  text-decoration-thickness: 2px;
}

/* Headings — Notion scale. Top-padding > bottom so a heading sits
 * visually grouped with the paragraph below it. */
.markdown-editor .tiptap h1 {
  font-size: 1.875em;
  font-weight: 700;
  line-height: 1.25;
  margin: 1em 0 0.25em;
  letter-spacing: -0.015em;
}

.markdown-editor .tiptap h2 {
  font-size: 1.5em;
  font-weight: 600;
  line-height: 1.3;
  margin: 0.9em 0 0.25em;
  letter-spacing: -0.01em;
}

.markdown-editor .tiptap h3 {
  font-size: 1.25em;
  font-weight: 600;
  line-height: 1.35;
  margin: 0.8em 0 0.2em;
}

.markdown-editor .tiptap h4 {
  font-size: 1.1em;
  font-weight: 600;
  line-height: 1.4;
  margin: 0.7em 0 0.2em;
}

/* First heading at the very top of the document has no leading air —
 * Notion convention. */
.markdown-editor .tiptap > :is(h1, h2, h3, h4):first-child {
  margin-top: 0;
}

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

/* Lists — Notion uses tighter row spacing than browser default. */
.markdown-editor .tiptap ul,
.markdown-editor .tiptap ol {
  padding-left: 1.5em;
  margin: 0.35em 0;
}

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

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

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

.markdown-editor .tiptap li > p {
  margin: 0;
}

/* Nested lists get a subtler marker. */
.markdown-editor .tiptap ul ul {
  list-style: circle;
}
.markdown-editor .tiptap ul ul ul {
  list-style: square;
}

/* Task list (GFM `- [ ] item`). StarterKit ships TaskList extension. */
.markdown-editor .tiptap ul[data-type="taskList"] {
  list-style: none;
  padding-left: 0.25em;
}

.markdown-editor .tiptap ul[data-type="taskList"] li {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
}

.markdown-editor .tiptap ul[data-type="taskList"] li > label {
  flex-shrink: 0;
  margin-top: 0.3em;
  user-select: none;
}

.markdown-editor .tiptap ul[data-type="taskList"] li > div {
  flex: 1;
  min-width: 0;
}

.markdown-editor .tiptap ul[data-type="taskList"] li[data-checked="true"] > div {
  opacity: 0.55;
  text-decoration: line-through;
}

/* Blockquote — Notion uses a chunky left bar without italic. */
.markdown-editor .tiptap blockquote {
  border-left: 3px solid var(--color-border, var(--border));
  padding: 0.2em 0 0.2em 1em;
  margin: 0.6em 0;
  color: color-mix(in oklab, var(--color-foreground, var(--foreground)) 80%, transparent);
}

.markdown-editor .tiptap blockquote > :first-child {
  margin-top: 0;
}
.markdown-editor .tiptap blockquote > :last-child {
  margin-bottom: 0;
}

/* Divider — full-width thin rule with breathing room. */
.markdown-editor .tiptap hr {
  border: none;
  border-top: 1px solid var(--color-border, var(--border));
  margin: 1.5em 0;
}

/* Inline code — monospace pill, restrained tint. */
.markdown-editor .tiptap code {
  background: color-mix(in oklab, var(--color-muted, var(--muted)) 70%, transparent);
  color: var(--color-foreground, var(--foreground));
  padding: 0.15em 0.35em;
  border-radius: 4px;
  font-size: 0.875em;
  font-family:
    "SF Mono", ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas,
    monospace;
  border: 1px solid color-mix(in oklab, var(--color-border, var(--border)) 60%, transparent);
}

/* Code block — darker surface so it stands apart from inline code. */
.markdown-editor .tiptap pre {
  background: var(--color-muted, var(--muted));
  color: var(--color-foreground, var(--foreground));
  padding: 0.9em 1em;
  border-radius: 6px;
  margin: 0.75em 0;
  font-family:
    "SF Mono", ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas,
    monospace;
  font-size: 0.875em;
  line-height: 1.55;
  overflow-x: auto;
  border: 1px solid color-mix(in oklab, var(--color-border, var(--border)) 50%, transparent);
}

.markdown-editor .tiptap pre code {
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  color: inherit;
}

/* Tables — borderless, subtle row separators (Notion-flavour). */
.markdown-editor .tiptap table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.75em 0;
  font-size: 0.95em;
  table-layout: fixed;
}

.markdown-editor .tiptap th,
.markdown-editor .tiptap td {
  border: 1px solid var(--color-border, var(--border));
  padding: 0.45em 0.75em;
  vertical-align: top;
  text-align: left;
  min-width: 4ch;
}

.markdown-editor .tiptap th {
  background: color-mix(in oklab, var(--color-muted, var(--muted)) 60%, transparent);
  font-weight: 600;
}

/* Images — rounded, never overflow. */
.markdown-editor .tiptap img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 0.5em 0;
}

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

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

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

/* Selection highlight — semantic ring colour, not browser-blue. */
.markdown-editor .tiptap ::selection {
  background: color-mix(in oklab, var(--color-primary, var(--primary)) 25%, transparent);
}

.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;
}

/* Slash-command inline chip — TipTap atom analogue of the plain
   `<SlashHighlightTextarea>` mirror. Mirrors `bg-primary/15 text-primary`
   so the two paths look identical. Atom nodes don't admit a caret, so
   light horizontal padding is safe here (unlike the plain mirror,
   which has to be padding-less to keep caret alignment). */
.markdown-slash-command {
  background: color-mix(in oklab, var(--color-primary, var(--primary)) 15%, transparent);
  color: var(--color-primary, var(--primary));
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 500;
  /* Atom nodes can't be entered; reflect that visually so the user does
     not try to click into the chip to edit it. */
  cursor: default;
  user-select: none;
  display: inline;
}

/* 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));
}
