/* ── md-editor ── bloque: editor Markdown con toolbar ─────────────────────── */

.md-editor {
  display: flex;
  flex-direction: column;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  height: calc(100vh - 160px);
  min-height: 520px;
}
.dark .md-editor { border-color: #30363d; background: #0d1117; }

/* ── Toolbar ── */
.md-editor__toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.dark .md-editor__toolbar { background: #161b22; border-color: #30363d; }

.md-editor__toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: ui-monospace, monospace;
  color: #374151;
  background: transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.dark .md-editor__toolbar-btn { color: #c9d1d9; }

.md-editor__toolbar-btn:hover {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #111827;
}
.dark .md-editor__toolbar-btn:hover {
  background: #21262d;
  border-color: #30363d;
  color: #f0f6fc;
}

.md-editor__toolbar-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: #e5e7eb;
  margin: 0 6px;
  flex-shrink: 0;
}
.dark .md-editor__toolbar-sep { background: #30363d; }

/* ── Textarea ── */
.md-editor__textarea {
  flex: 1;
  width: 100%;
  padding: 20px 24px;
  border: none;
  outline: none;
  resize: none;
  font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.9rem;
  line-height: 1.75;
  color: #1f2937;
  background: #fff;
  tab-size: 2;
  min-height: 0;
}
.dark .md-editor__textarea {
  background: #0d1117;
  color: #e6edf3;
}

/* ── Preview ── */
.md-editor__preview {
  flex: 1;
  padding: 20px 32px;
  overflow-y: auto;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.8;
  color: #1f2937;
  min-height: 0;
}
.dark .md-editor__preview { color: #e6edf3; }

/* Tipografía del preview */
.md-editor__preview h1,
.md-editor__preview h2,
.md-editor__preview h3 {
  font-weight: 700;
  margin: 1.25em 0 0.5em;
  color: #111827;
  line-height: 1.3;
}
.dark .md-editor__preview h1,
.dark .md-editor__preview h2,
.dark .md-editor__preview h3 { color: #f0f6fc; }

.md-editor__preview h1 { font-size: 1.5rem; }
.md-editor__preview h2 { font-size: 1.25rem; }
.md-editor__preview h3 { font-size: 1.1rem; }

.md-editor__preview p  { margin: 0 0 1em; }

.md-editor__preview a  { color: #E87524; text-decoration: underline; }

.md-editor__preview strong { font-weight: 700; }
.md-editor__preview em     { font-style: italic; }

.md-editor__preview code {
  font-family: ui-monospace, monospace;
  font-size: 0.85em;
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 4px;
  color: #374151;
}
.dark .md-editor__preview code { background: #21262d; color: #e6edf3; }

.md-editor__preview pre {
  background: #f3f4f6;
  border-radius: 8px;
  padding: 14px 18px;
  overflow-x: auto;
  margin: 0 0 1em;
}
.dark .md-editor__preview pre { background: #161b22; }

.md-editor__preview pre code {
  background: none;
  padding: 0;
  font-size: 0.875rem;
}

.md-editor__preview blockquote {
  border-left: 3px solid #E87524;
  margin: 0 0 1em;
  padding: 4px 0 4px 16px;
  color: #6b7280;
}

.md-editor__preview hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 1.5em 0;
}
.dark .md-editor__preview hr { border-color: #30363d; }

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

.md-editor__preview img {
  max-width: 100%;
  border-radius: 6px;
  margin: 8px 0;
}

/* ── Contador ── */
.md-editor__counter {
  font-size: 0.72rem;
  color: #9ca3af;
  padding: 5px 16px;
  border-top: 1px solid #f3f4f6;
  text-align: right;
  flex-shrink: 0;
  background: #f9fafb;
}
.dark .md-editor__counter { background: #161b22; border-color: #21262d; }

/* ── Botones especiales ── */
.md-editor__toolbar-btn--ia {
  color: #E87524;
  border-color: #E87524 !important;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.md-editor__toolbar-btn--ia:hover    { background: #fff7f0 !important; }
.dark .md-editor__toolbar-btn--ia:hover { background: #1a0f00 !important; }
.md-editor__toolbar-btn--ia:disabled { opacity: 0.5; cursor: not-allowed; }

.md-editor__toolbar-btn--preview {
  font-family: system-ui, sans-serif;
  font-size: 0.775rem;
}

/* ── Toast ── */
.md-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: #111827;
  color: #f3f4f6;
  font-size: 0.82rem;
  padding: 9px 18px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 9999;
  white-space: nowrap;
  pointer-events: none;
}
.md-toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.md-toast--error   { background: #7f1d1d; }