.editor-root {
  --editor-border: rgba(128, 128, 128, 0.35);
  --editor-toolbar-bg: transparent;
  --editor-surface: transparent;
  --editor-text: inherit;
  --editor-placeholder: rgba(128, 128, 128, 0.9);
  --editor-accent: currentColor;
  --editor-hover-bg: rgba(128, 128, 128, 0.15);
  --editor-radius: 8px;
  --editor-min-height: 180px;
  --editor-font-size: 15px;

  border: 1px solid var(--editor-border);
  border-radius: var(--editor-radius);
  background: var(--editor-surface);
  overflow: hidden;
}

/* TOOLBAR */

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 6px 8px;
  background: var(--editor-toolbar-bg);
  border-bottom: 1px solid var(--editor-border);
}

.editor-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.editor-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  padding: 0 5px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--editor-text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
}

.editor-button .material-symbols-outlined {
  font-size: 19px;
  line-height: 1;
}

.editor-button:hover:not(:disabled),
.editor-button:focus-visible {
  background: var(--editor-hover-bg);
}

.editor-button.is-active {
  color: var(--editor-accent);
  background: var(--editor-hover-bg);
}

.editor-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.editor-button--text {
  width: auto;
  min-width: 0;
  padding: 0 8px;
  font-size: 13px;
}

.editor-select {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.editor-select__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.editor-select__control {
  height: 28px;
  padding: 0 4px;
  border: 1px solid var(--editor-border);
  border-radius: 4px;
  background: transparent;
  color: var(--editor-text);
  font-family: inherit;
  font-size: 13px;
}

/* PROSEMIRROR BASE */

.ProseMirror {
  position: relative;
  word-wrap: break-word;
  white-space: pre-wrap;
  white-space: break-spaces;
  -webkit-font-variant-ligatures: none;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0;
}

.ProseMirror [contenteditable="false"] {
  white-space: normal;
}

.ProseMirror [contenteditable="false"] [contenteditable="true"] {
  white-space: pre-wrap;
}

.ProseMirror pre {
  white-space: pre-wrap;
}

img.ProseMirror-separator {
  display: inline !important;
  border: none !important;
  margin: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

.ProseMirror-gapcursor {
  display: none;
  pointer-events: none;
  position: absolute;
  margin: 0;
}

.ProseMirror-gapcursor::after {
  content: "";
  display: block;
  position: absolute;
  top: -2px;
  width: 20px;
  border-top: 1px solid currentColor;
  animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}

@keyframes ProseMirror-cursor-blink {
  to {
    visibility: hidden;
  }
}

.ProseMirror-hideselection *::selection {
  background: transparent;
}

.ProseMirror-hideselection *::-moz-selection {
  background: transparent;
}

.ProseMirror-hideselection * {
  caret-color: transparent;
}

.ProseMirror-focused .ProseMirror-gapcursor {
  display: block;
}

/* EDITABLE AREA */

.editor-content {
  min-height: var(--editor-min-height);
  padding: 12px 15px;
  color: var(--editor-text);
  font-size: var(--editor-font-size);
  line-height: 1.6;
  overflow-wrap: break-word;
}

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

.editor-content > :first-child {
  margin-top: 0;
}

.editor-content > :last-child {
  margin-bottom: 0;
}

.editor-content h1,
.editor-content h2,
.editor-content h3 {
  margin: 1.2em 0 0.5em;
  padding: 0;
  border: 0;
  font-weight: 700;
  line-height: 1.25;
}

.editor-content h1 { font-size: 1.6em; }
.editor-content h2 { font-size: 1.35em; }
.editor-content h3 { font-size: 1.15em; }

.editor-content p {
  margin: 0 0 0.75em;
}

.editor-content ul,
.editor-content ol {
  margin: 0 0 0.75em;
  padding-left: 1.75em;
}

.editor-content blockquote {
  margin: 0.5em 0;
  padding-left: 16px;
  border-left: 4px solid var(--editor-border);
}

.editor-content pre {
  padding: 10px 12px;
  border-radius: 4px;
  background: rgba(128, 128, 128, 0.18);
  overflow-x: auto;
}

.editor-content code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.92em;
}

.editor-content hr {
  margin: 1em 0;
  border: 0;
  border-top: 1px solid var(--editor-border);
}

.editor-content img,
.editor-content iframe {
  max-width: 100%;
}

.editor-content table {
  width: 100%;
  margin: 14px 0;
  border-collapse: collapse;
}

.editor-content th,
.editor-content td {
  padding: 8px 10px;
  border: 1px solid var(--editor-border);
}

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

/* MENTION DROPDOWN */

.editor-mention-list {
  position: absolute;
  z-index: 9001;
  min-width: 220px;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #1a1a1a;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.editor-mention-list__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.editor-mention-list__item:hover,
.editor-mention-list__item.is-selected {
  background: rgba(255, 255, 255, 0.08);
}

/* LINK POPOVER */

.editor-link-popover {
  position: absolute;
  z-index: 9001;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--editor-border, #333);
  border-radius: 8px;
  background: #1a1a1a;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.editor-link-popover__input {
  width: 240px;
  max-width: 60vw;
  padding: 6px 8px;
  border: 1px solid var(--editor-border, #333);
  border-radius: 4px;
  background: #0e0e0e;
  color: #ddd;
  font-size: 13px;
}

.editor-link-popover__input.is-invalid {
  border-color: #ee2445;
}

/* MOBILE */

@media (max-width: 600px) {
  .editor-toolbar {
    gap: 2px 8px;
  }

  .editor-button {
    min-width: 34px;
    height: 34px;
  }

  .editor-link-popover__input {
    width: 180px;
  }
}

/* TABLE MENU */

.editor-table-menu {
  position: absolute;
  z-index: 9001;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 260px;
  max-width: 90vw;
  padding: 12px;
  border: 1px solid var(--editor-border, #d7dde7);
  border-radius: 8px;
  background: #fff;
  color: #1f2937;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.editor-table-menu[hidden] {
  display: none;
}

.editor-table-menu__section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-table-menu__title {
  font-size: 12px;
  font-weight: 700;
  color: #516278;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.editor-table-menu__size {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr;
  align-items: center;
  gap: 6px;
}

.editor-table-menu__size-label {
  font-size: 12px;
  color: #516278;
}

.editor-table-menu__number {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid #d7dde7;
  border-radius: 4px;
  font-size: 13px;
}

.editor-table-menu__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.editor-table-menu__action {
  padding: 7px 9px;
  border: 1px solid #d7dde7;
  border-radius: 6px;
  background: #f8fafc;
  color: #1f2937;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.editor-table-menu__action:hover:not(:disabled) {
  border-color: #94a3b8;
  background: #eef2f7;
  color: #0f172a;
}

.editor-table-menu__action:disabled {
  color: #94a3b8;
  opacity: 0.7;
  cursor: default;
}

.editor-table-menu__action.is-primary {
  border-color: #1d4ed8;
  background: #1d4ed8;
  color: #fff;
}

.editor-table-menu__action.is-primary:hover:not(:disabled) {
  background: #1e40af;
}

.editor-table-menu__action.is-danger:hover:not(:disabled) {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #b91c1c;
}

.editor-table-menu__action.is-wide {
  grid-column: 1 / -1;
}

.editor-table-menu__hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  color: #64748b;
}

.editor-content .selectedCell {
  position: relative;
}

.editor-content .selectedCell::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(29, 78, 216, 0.12);
  pointer-events: none;
}

/* CALLOUTS */

.editor-content aside {
  position: static;
  z-index: auto;
  display: block;
  width: auto;
  height: auto;
  overflow-x: visible;
  overflow-y: visible;
  flex-flow: row nowrap;
  scrollbar-gutter: auto;
  scroll-padding-bottom: 0;
  background-color: transparent;
}

.editor-content aside[data-callout] {
  --editor-callout: 37, 99, 235;

  position: relative;
  margin: 1rem 0;
  padding: 0.85rem 1rem 0.85rem 2.75rem;
  border: 1px solid rgba(var(--editor-callout), 0.35);
  border-left-width: 3px;
  border-radius: 6px;
  background-color: rgba(var(--editor-callout), 0.06);
  color: inherit;
}

.editor-content aside[data-callout]::before {
  position: absolute;
  top: 0.9rem;
  left: 0.9rem;
  color: rgb(var(--editor-callout));
  font-family: "Material Symbols Outlined";
  font-size: 1.15rem;
  line-height: 1;
}

.editor-content aside[data-callout="info"]::before { content: "info"; }

.editor-content aside[data-callout="success"] { --editor-callout: 22, 163, 74; }
.editor-content aside[data-callout="success"]::before { content: "check_circle"; }

.editor-content aside[data-callout="warning"] { --editor-callout: 217, 119, 6; }
.editor-content aside[data-callout="warning"]::before { content: "warning"; }

.editor-content aside[data-callout="danger"] { --editor-callout: 220, 38, 38; }
.editor-content aside[data-callout="danger"]::before { content: "error"; }

.editor-content aside[data-callout="tip"] { --editor-callout: 8, 145, 178; }
.editor-content aside[data-callout="tip"]::before { content: "lightbulb"; }
