.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

.editor-toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border-right: 1px solid var(--border-color);
}

.editor-toolbar-group:last-child {
  border-right: none;
}

.editor-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  color: var(--text-primary);
  background-color: transparent;
  border: 1px solid transparent;
  transition: all var(--transition);
}

.editor-btn:hover {
  background-color: var(--border-color);
}

.editor-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.editor-btn.active {
  background-color: var(--accent);
  color: var(--bg-primary);
}

.editor-btn svg {
  width: 18px;
  height: 18px;
}

.editor-btn.select-trigger {
  width: auto;
  padding: 0 12px 0 8px;
  gap: 4px;
  font-size: 0.8125rem;
  font-weight: 500;
}

.editor-btn.select-trigger svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.editor-content {
  min-height: 400px;
  padding: 24px;
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background-color: var(--bg-primary);
  outline: none;
  line-height: 1.7;
}

.editor-content:focus {
  box-shadow: inset 0 0 0 2px var(--accent);
}

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

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

.editor-content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 1.5em 0 0.5em;
  line-height: 1.3;
}

.editor-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 1.5em 0 0.5em;
  line-height: 1.4;
}

.editor-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 1.5em 0 0.5em;
  line-height: 1.4;
}

.editor-content p {
  margin-bottom: 1em;
}

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

.editor-content li {
  margin-bottom: 0.5em;
}

.editor-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1em;
  margin: 1em 0;
  color: var(--text-secondary);
  font-style: italic;
}

.editor-content code {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.9em;
  background-color: var(--bg-secondary);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--border-color);
}

.editor-content pre {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 1em;
  overflow-x: auto;
  margin: 1em 0;
}

.editor-content pre code {
  background: none;
  padding: 0;
  border: none;
  font-size: 0.875rem;
  line-height: 1.6;
}

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

.editor-content strong {
  font-weight: 600;
}

.editor-content em {
  font-style: italic;
}

.editor-content u {
  text-decoration: underline;
}

.editor-content del {
  text-decoration: line-through;
}

.editor-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.editor-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1em 0;
}

.editor-placeholder {
  color: var(--text-muted);
  pointer-events: none;
}

@media (max-width: 768px) {
  .editor-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0;
    padding: 6px 4px;
  }

  .editor-toolbar::-webkit-scrollbar {
    display: none;
  }

  .editor-toolbar-group {
    flex-shrink: 0;
    padding: 0 4px;
    gap: 2px;
  }

  .editor-toolbar-divider {
    flex-shrink: 0;
    margin: 0 4px;
  }

  .editor-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }

  .editor-btn.select-trigger {
    padding: 0 8px;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  .editor-content {
    padding: 16px;
    min-height: 300px;
    font-size: 1rem;
  }
}

/* -- Lucide icon sizing inside editor buttons -------------------------------- */
.editor-btn i[data-lucide],
.editor-btn svg {
  width: 17px;
  height: 17px;
  display: block;
  flex-shrink: 0;
}

/* Text-label buttons (H1 / H2 / H3) */
.editor-btn-text {
  width: auto;
  min-width: 34px;
  padding: 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* -- Link popover ------------------------------------------------------------ */
.link-popover {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
  z-index: 300;
  animation: fadeUpIn 120ms ease;
  min-width: 280px;
}

[data-theme="dark"] .link-popover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.3);
}

@keyframes fadeUpIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.link-popover-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 0.8125rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 150ms ease;
}

.link-popover-input:focus {
  border-color: var(--accent);
}

.link-popover-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 150ms ease;
  flex-shrink: 0;
}

.link-popover-apply {
  color: var(--accent);
}

.link-popover-apply:hover {
  background: var(--bg-secondary);
  color: var(--accent);
}

.link-popover-remove:hover {
  background: #fef2f2;
  color: #dc2626;
}

[data-theme="dark"] .link-popover-remove:hover {
  background: #450a0a;
}

/* -- Justified text --------------------------------------------------------- */
.editor-content [style*="text-align: justify"],
.editor-content p[style*="text-align:justify"] {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Color picker buttons */
.color-picker-wrap {
  position: relative;
  display: flex;
}

.editor-color-btn {
  flex-direction: column;
  gap: 2px;
  height: 36px;
  width: 32px;
  padding: 4px 0 2px;
}

.color-indicator {
  display: block;
  width: 18px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}
