/* ExpertEditor standalone CSS (variables + editor) */
/* ============================================================
   variables.css — CSS variables do tema do ExpertEditor (§24-25)
   Não assume identidade visual fixa; permite integração com
   diferentes Design Systems e suporte a dark mode.
   ============================================================ */

:root {
  /* Cor de marca */
  --editor-primary: #2563eb;
  --editor-primary-hover: #1d4ed8;
  --editor-primary-soft: rgba(37, 99, 235, 0.12);
  --editor-primary-contrast: #ffffff;

  /* Superfícies */
  --editor-background: #ffffff;
  --editor-surface: #ffffff;
  --editor-surface-alt: #f9fafb;
  --editor-toolbar-background: #ffffff;
  --editor-toolbar-active: rgba(37, 99, 235, 0.10);

  /* Bordas */
  --editor-border: #e5e7eb;
  --editor-border-strong: #d1d5db;

  /* Texto */
  --editor-text: #1f2937;
  --editor-muted: #6b7280;
  --editor-placeholder: #9ca3af;

  /* Estados */
  --editor-hover: #f3f4f6;
  --editor-active-text: #1d4ed8;
  --editor-icon: #4b5563;
  --editor-focus-ring: rgba(37, 99, 235, 0.35);

  /* Radii */
  --editor-radius: 8px;
  --editor-radius-lg: 12px;
  --editor-radius-sm: 6px;

  /* Sombras */
  --editor-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --editor-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 14px rgba(15, 23, 42, 0.06);
  --editor-shadow-focus: 0 0 0 3px var(--editor-focus-ring);

  /* Tipografia */
  --editor-font-family: 'Inter', ui-sans-serif, system-ui, -apple-system,
    'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Transições */
  --editor-transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode explícito (atributo data-theme="dark" ou classe .dark no ancestor) */
[data-theme='dark'],
.dark {
  --editor-primary: #3b82f6;
  --editor-primary-hover: #60a5fa;
  --editor-primary-soft: rgba(59, 130, 246, 0.16);
  --editor-primary-contrast: #ffffff;

  --editor-background: #0f172a;
  --editor-surface: #1e293b;
  --editor-surface-alt: #111827;
  --editor-toolbar-background: #1e293b;
  --editor-toolbar-active: rgba(59, 130, 246, 0.18);

  --editor-border: #334155;
  --editor-border-strong: #475569;

  --editor-text: #e2e8f0;
  --editor-muted: #94a3b8;
  --editor-placeholder: #64748b;

  --editor-hover: #334155;
  --editor-active-text: #93c5fd;
  --editor-icon: #cbd5e1;
  --editor-focus-ring: rgba(59, 130, 246, 0.45);

  --editor-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --editor-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 4px 16px rgba(0, 0, 0, 0.35);
  --editor-shadow-focus: 0 0 0 3px var(--editor-focus-ring);
}

/* ============================================================
   editor.css — Estilos base do ExpertEditor.
   Usa apenas CSS variables (tema/dark mode via variables.css).
   ============================================================ */

.expert-editor {
  position: relative;
  font-family: var(--editor-font-family, ui-sans-serif, system-ui, sans-serif);
  color: var(--editor-text);
  background: var(--editor-background);
  border: 1px solid var(--editor-border, #e5e7eb);
  border-radius: var(--editor-radius, 8px);
  box-shadow: var(--editor-shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.05));
  transition: border-color var(--editor-transition, 150ms),
    box-shadow var(--editor-transition, 150ms), background var(--editor-transition, 150ms);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* Área de edição (ProseMirror) */
.expert-editor__prosemirror {
  outline: none;
  padding: 20px 22px;
  min-height: 360px;
  line-height: 1.7;
  font-size: 15px;
  caret-color: var(--editor-primary);
  transition: box-shadow var(--editor-transition, 150ms);
}

.expert-editor__prosemirror:focus {
  box-shadow: var(--editor-shadow-focus, 0 0 0 3px rgba(37, 99, 235, 0.35));
}

/* Modo código (HTML): área de edição raw substitui a visual */
.expert-editor__source {
  display: none; /* controlado via style no core */
  min-height: 360px;
}
.expert-editor__source-textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 360px;
  padding: 16px 20px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--editor-text, #1f2937);
  background: var(--editor-surface-alt, #f8fafc);
  border: none;
  border-radius: 0 0 var(--editor-radius, 8px) var(--editor-radius, 8px);
  outline: none;
  resize: vertical;
  caret-color: var(--editor-primary);
  -moz-tab-size: 2;
  tab-size: 2;
}
.expert-editor__source-textarea:focus {
  box-shadow: inset 0 0 0 2px var(--editor-focus-ring, rgba(37, 99, 235, 0.35));
}

/* Bloco HTML cru (signatura/HTML pronto) — renderizado íntegro */
.expert-editor__raw {
  position: relative;
  margin: 0.6em 0;
  padding: 8px;
  border: 1px dashed var(--editor-border-strong, #d1d5db);
  border-radius: var(--editor-radius-sm, 6px);
  background: var(--editor-surface-alt, #f9fafb);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.expert-editor__raw > *:first-child { margin-top: 0; }
.expert-editor__raw > *:last-child { margin-bottom: 0; }
.expert-editor__raw img { max-width: 100%; height: auto; }

/* Placeholder */
.expert-editor[data-placeholder] .expert-editor__prosemirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  height: 0;
  pointer-events: none;
  color: var(--editor-placeholder, #9ca3af);
  font-style: italic;
  opacity: 0.8;
}

/* Tipografia base (Tiptap StarterKit output) */
.expert-editor .expert-editor__prosemirror h1 {
  font-size: 2.1em;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0.8em 0 0.45em;
  line-height: 1.25;
}
.expert-editor .expert-editor__prosemirror h2 {
  font-size: 1.55em;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0.75em 0 0.4em;
  line-height: 1.3;
}
.expert-editor .expert-editor__prosemirror h3 {
  font-size: 1.28em;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0.7em 0 0.35em;
  line-height: 1.35;
}
.expert-editor .expert-editor__prosemirror p {
  margin: 0 0 0.8em;
}
.expert-editor .expert-editor__prosemirror ul,
.expert-editor .expert-editor__prosemirror ol {
  padding-left: 1.5em;
  margin: 0 0 0.8em;
}
.expert-editor .expert-editor__prosemirror li {
  margin: 0.15em 0;
}
.expert-editor .expert-editor__prosemirror ::selection {
  background: var(--editor-primary-soft, rgba(37, 99, 235, 0.12));
}

/* Modo readonly: oculta controles de edição e cursor de edição (§10) */
.expert-editor[data-readonly='true'] .expert-editor__toolbar {
  display: none;
}
.expert-editor[data-readonly='true'] .expert-editor__prosemirror {
  cursor: default;
  opacity: 0.9;
}

/* Toolbar interna do editor (exposta caso o host use .expert-editor__toolbar) */
.expert-editor__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--editor-border, #e5e7eb);
  background: var(--editor-toolbar-background, #f9fafb);
}

/* Botões de toolbar (usados tanto pela toolbar interna quanto pelo playground) */
.expert-editor__toolbar button,
.expert-editor .toolbar button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--editor-icon, #4b5563);
  border-radius: var(--editor-radius-sm, 6px);
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
  transition: background var(--editor-transition, 150ms),
    color var(--editor-transition, 150ms), border-color var(--editor-transition, 150ms),
    box-shadow var(--editor-transition, 150ms), transform var(--editor-transition, 150ms);
}

.expert-editor__toolbar button:hover,
.expert-editor .toolbar button:hover {
  background: var(--editor-hover, #f3f4f6);
  color: var(--editor-text, #1f2937);
}

.expert-editor__toolbar button:active,
.expert-editor .toolbar button:active {
  transform: translateY(1px);
}

.expert-editor__toolbar button:focus-visible,
.expert-editor .toolbar button:focus-visible {
  outline: none;
  box-shadow: var(--editor-shadow-focus, 0 0 0 3px rgba(37, 99, 235, 0.35));
}

/* Estado ativo/selected (ex.: comando aplicado em ativação de bloco/estilo) */
.expert-editor__toolbar button.is-active,
.expert-editor .toolbar button.is-active {
  background: var(--editor-primary-soft, rgba(37, 99, 235, 0.12));
  color: var(--editor-active-text, #1d4ed8);
  border-color: var(--editor-primary, #2563eb);
}

/* Botões "ícone" — compactos, por ex. undo/redo (⟲ ⟳) */
.expert-editor__toolbar button[data-icon],
.expert-editor .toolbar button:not(:has(span)) {
  min-width: 30px;
  justify-content: center;
}

/* Separador útil em toolbars */
.expert-editor__toolbar .toolbar-sep,
.expert-editor .toolbar .toolbar-sep {
  width: 1px;
  align-self: stretch;
  margin: 2px 4px;
  background: var(--editor-border-strong, #d1d5db);
}

/* ============================================================
   Toolbar profissional (Fase 2) — ícones SVG + tooltip + grupos.
   Usa as variables de tema (light/dark via variables.css).
   ============================================================ */

.ee-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 8px;
  margin-bottom: 10px;
  background: var(--editor-toolbar-background, #ffffff);
  border: 1px solid var(--editor-border, #e5e7eb);
  border-radius: var(--editor-radius-sm, 6px);
}

/* Botão de toolbar: quadrado 36px, ícone centralizado */
.ee-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--editor-radius-sm, 6px);
  background: transparent;
  color: var(--editor-icon, #4b5563);
  cursor: pointer;
  transition: background var(--editor-transition, 150ms),
    color var(--editor-transition, 150ms), border-color var(--editor-transition, 150ms),
    box-shadow var(--editor-transition, 150ms), transform var(--editor-transition, 150ms);
  touch-action: manipulation;
}

.ee-btn .ee-ico {
  width: 19px;
  height: 19px;
  pointer-events: none;
}

.ee-btn:hover {
  background: var(--editor-hover, #f3f4f6);
  color: var(--editor-text, #1f2937);
  border-color: var(--editor-border-strong, #d1d5db);
}

.ee-btn:active {
  transform: translateY(1px);
}

.ee-btn:focus-visible {
  outline: none;
  box-shadow: var(--editor-shadow-focus, 0 0 0 3px rgba(37, 99, 235, 0.35));
}

/* Estado ativo (formatação aplicada à seleção) */
.ee-btn.is-active {
  background: var(--editor-toolbar-active, rgba(37, 99, 235, 0.10));
  color: var(--editor-active-text, #1d4ed8);
  border-color: var(--editor-primary, #2563eb);
}

/* ── Tooltip (CSS puro via data-tooltip + ::after) ───────── */
.ee-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  z-index: 40;
  max-width: max-content;
  padding: 5px 9px;
  border-radius: 6px;
  background: #1f2937;
  color: #f9fafb;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease 240ms, transform 120ms ease 240ms;
}

/* Setinha do tooltip */
.ee-btn[data-tooltip]::before {
  content: '';
  position: absolute;
  top: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid #1f2937;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease 240ms;
}

/* Hover + foco exibem o tooltip (com leve atraso) */
.ee-btn[data-tooltip]:hover::after,
.ee-btn[data-tooltip]:hover::before,
.ee-btn[data-tooltip]:focus-visible::after,
.ee-btn[data-tooltip]:focus-visible::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Seta: não move vertical (mantém ancorada) */
.ee-btn[data-tooltip]:hover::before,
.ee-btn[data-tooltip]:focus-visible::before {
  transform: translateX(-50%);
}

/* Tooltip na última fileira: flutua acima para não cortar no viewport */
.ee-toolbar > .ee-btn:last-of-type[data-tooltip]::after,
.ee-toolbar > .ee-btn:nth-last-child(2)[data-tooltip]::after {
  top: auto;
  bottom: calc(100% + 7px);
  transform: translateX(-50%) translateY(4px);
}
.ee-toolbar > .ee-btn:last-of-type[data-tooltip]::before,
.ee-toolbar > .ee-btn:nth-last-child(2)[data-tooltip]::before {
  top: auto;
  bottom: calc(100% + 3px);
  border-bottom: 0;
  border-top: 5px solid #1f2937;
}
.ee-toolbar > .ee-btn:last-of-type[data-tooltip]:hover::after,
.ee-toolbar > .ee-btn:last-of-type[data-tooltip]:hover::before,
.ee-toolbar > .ee-btn:nth-last-child(2)[data-tooltip]:hover::after,
.ee-toolbar > .ee-btn:nth-last-child(2)[data-tooltip]:hover::before,
.ee-toolbar > .ee-btn:last-of-type[data-tooltip]:focus-visible::after,
.ee-toolbar > .ee-btn:last-of-type[data-tooltip]:focus-visible::before,
.ee-toolbar > .ee-btn:nth-last-child(2)[data-tooltip]:focus-visible::after,
.ee-toolbar > .ee-btn:nth-last-child(2)[data-tooltip]:focus-visible::before {
  transform: translateX(-50%) translateY(0);
}

/* Tooltip em dark mode: caixa clara p/ contraste */
[data-theme='dark'] .ee-btn[data-tooltip]::after,
.dark .ee-btn[data-tooltip]::after {
  background: #e2e8f0;
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
[data-theme='dark'] .ee-btn[data-tooltip]::before,
.dark .ee-btn[data-tooltip]::before {
  border-bottom-color: #e2e8f0;
}
[data-theme='dark'] .ee-toolbar > .ee-btn:last-of-type[data-tooltip]::before,
[data-theme='dark'] .ee-toolbar > .ee-btn:nth-last-child(2)[data-tooltip]::before,
.dark .ee-toolbar > .ee-btn:last-of-type[data-tooltip]::before,
.dark .ee-toolbar > .ee-btn:nth-last-child(2)[data-tooltip]::before {
  border-top-color: #e2e8f0;
}

/* ── Separador entre grupos ─────────────────────────────── */
.ee-sep {
  width: 1px;
  align-self: stretch;
  min-height: 20px;
  margin: 0 5px;
  background: var(--editor-border-strong, #d1d5db);
}

/* ── Fase 4: responsividade mobile (toolbar não quebra) ─── */
@media (max-width: 640px) {
  .ee-toolbar {
    gap: 2px;
    padding: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .ee-toolbar::-webkit-scrollbar { display: none; }
  .ee-btn { width: 32px; height: 32px; flex: 0 0 auto; }
  .ee-btn--text { width: auto; padding: 0 9px; }
  .ee-btn .ee-ico { width: 17px; height: 17px; }
  .ee-sep { margin: 0 3px; }
}

/* ── Fase 4: dark mode refinado (toolbar/floating/statusbar) ── */
[data-theme='dark'] .ee-toolbar,
.dark .ee-toolbar {
  background: rgba(15, 23, 42, 0.55);
  border-color: rgba(148, 163, 184, 0.16);
}
[data-theme='dark'] .ee-floating__menu,
.dark .ee-floating__menu {
  background: #1e293b;
  border-color: rgba(148, 163, 184, 0.2);
}
[data-theme='dark'] .ee-statusbar,
.dark .ee-statusbar {
  background: rgba(15, 23, 42, 0.35);
  border-color: rgba(148, 163, 184, 0.16);
}

/* ============================================================
   Tabelas — UI avançada (TASK-GE-OS-01)
   Popover de inserção (grade seletora) + barra contextual flutuante.
   ============================================================ */

/* Variantes de botão usadas no popover e na barra de tabela */
.ee-btn--ghost {
  background: transparent;
  color: var(--editor-icon, #4b5563);
  border-color: var(--editor-border, #e5e7eb);
}
.ee-btn--ghost:hover {
  background: var(--editor-hover, #f3f4f6);
  color: var(--editor-text, #1f2937);
  border-color: var(--editor-border-strong, #d1d5db);
}
.ee-btn--primary {
  background: var(--editor-primary, #2563eb);
  color: var(--editor-primary-contrast, #ffffff);
  border-color: var(--editor-primary, #2563eb);
}
.ee-btn--primary:hover {
  background: var(--editor-primary-hover, #1d4ed8);
  border-color: var(--editor-primary-hover, #1d4ed8);
}

/* ── Popover de inserção de tabela ───────────────────────── */
.ee-table-popover {
  position: fixed;
  z-index: 60;
  min-width: 260px;
  padding: 14px;
  background: var(--editor-surface, #ffffff);
  border: 1px solid var(--editor-border, #e5e7eb);
  border-radius: var(--editor-radius-lg, 12px);
  box-shadow: var(--editor-shadow, 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 14px rgba(15, 23, 42, 0.06));
}
.ee-table-popover__inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ee-table-popover__title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--editor-text, #1f2937);
}

/* Grade seletora 10×10 */
.ee-table-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--editor-border, #e5e7eb);
  border-radius: var(--editor-radius-sm, 6px);
  background: var(--editor-surface-alt, #f9fafb);
  align-self: flex-start;
}
.ee-table-grid__cell {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--editor-border-strong, #d1d5db);
  border-radius: 3px;
  background: var(--editor-surface, #ffffff);
  cursor: pointer;
  transition: background var(--editor-transition, 150ms), border-color var(--editor-transition, 150ms);
}
.ee-table-grid__cell:hover,
.ee-table-grid__cell.is-hovered {
  background: var(--editor-primary, #2563eb);
  border-color: var(--editor-primary-hover, #1d4ed8);
}
.ee-table-popover__label {
  font-size: 12px;
  color: var(--editor-muted, #6b7280);
  font-weight: 500;
}

/* Campos numéricos */
.ee-table-popover__fields {
  display: flex;
  gap: 12px;
}
.ee-table-popover__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.ee-table-popover__field-label {
  font-size: 11.5px;
  color: var(--editor-muted, #6b7280);
  font-weight: 500;
}
.ee-table-popover__field input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--editor-text, #1f2937);
  background: var(--editor-surface, #ffffff);
  border: 1px solid var(--editor-border, #e5e7eb);
  border-radius: var(--editor-radius-sm, 6px);
  outline: none;
  transition: border-color var(--editor-transition, 150ms), box-shadow var(--editor-transition, 150ms);
}
.ee-table-popover__field input:focus {
  border-color: var(--editor-primary, #2563eb);
  box-shadow: var(--editor-shadow-focus, 0 0 0 3px rgba(37, 99, 235, 0.35));
}

/* Checkbox de cabeçalho + ações */
.ee-table-popover__option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--editor-text, #1f2937);
  cursor: pointer;
  user-select: none;
}
.ee-table-popover__option input {
  accent-color: var(--editor-primary, #2563eb);
}
.ee-table-popover__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}
.ee-table-popover__btn {
  width: auto;
  height: 32px;
  padding: 0 14px;
  font-size: 12.5px;
  font-weight: 500;
}

/* ── Barra contextual de tabela (ícones compactos + tooltip) ── */
.ee-tablebar {
  position: fixed;
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100vw - 16px);
  padding: 4px 6px;
  flex-wrap: wrap;
  background: var(--editor-surface, #ffffff);
  border: 1px solid var(--editor-border, #e5e7eb);
  border-radius: var(--editor-radius-lg, 12px);
  box-shadow: var(--editor-shadow, 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 14px rgba(15, 23, 42, 0.06));
}

/* Botões de ícone compactos (substituem a lista longa de texto) */
.ee-tablebar__btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ee-tablebar__btn .ee-ico {
  width: 17px;
  height: 17px;
}
.ee-tablebar__btn--danger {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.35);
}
.ee-tablebar__btn--danger:hover {
  background: rgba(220, 38, 38, 0.10);
  border-color: #dc2626;
  color: #b91c1c;
}
.ee-tablebar .ee-sep {
  height: 20px;
  margin: 0 2px;
}

/* Botão flutuante mobile: ferramentas de tabela (só <=640px) */
.ee-tablebar__fab {
  position: fixed;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--editor-border, #e5e7eb);
  border-radius: 50%;
  box-shadow: var(--editor-shadow, 0 1px 3px rgba(15, 23, 42, 0.12), 0 4px 14px rgba(15, 23, 42, 0.1));
  background: var(--editor-surface, #ffffff);
  color: var(--editor-primary, #2563eb);
  cursor: pointer;
  transition: background var(--editor-transition, 150ms), transform var(--editor-transition, 150ms);
}
.ee-tablebar__fab:hover {
  background: var(--editor-primary-soft, rgba(37, 99, 235, 0.12));
}
.ee-tablebar__fab:active {
  transform: scale(0.94);
}
.ee-tablebar__fab:focus-visible {
  outline: none;
  box-shadow: var(--editor-shadow-focus, 0 0 0 3px rgba(37, 99, 235, 0.35));
}

/* Menu/action-sheet mobile em grade (2 colunas) com todas as ações */
.ee-tablebar__menu {
  position: fixed;
  z-index: 65;
  width: 280px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  background: var(--editor-surface, #ffffff);
  border: 1px solid var(--editor-border, #e5e7eb);
  border-radius: var(--editor-radius-lg, 12px);
  box-shadow: var(--editor-shadow, 0 1px 3px rgba(15, 23, 42, 0.12), 0 4px 16px rgba(15, 23, 42, 0.14));
}
.ee-tablebar__menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  color: var(--editor-text, #1f2937);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--editor-radius-sm, 6px);
  cursor: pointer;
}
.ee-tablebar__menu-item:hover {
  background: var(--editor-hover, #f3f4f6);
}
.ee-tablebar__menu-item:focus-visible {
  outline: none;
  box-shadow: var(--editor-shadow-focus, 0 0 0 3px rgba(37, 99, 235, 0.35));
}
.ee-tablebar__menu-ic {
  display: inline-flex;
  color: var(--editor-icon, #4b5563);
}
.ee-tablebar__menu-item--danger {
  color: #dc2626;
}
.ee-tablebar__menu-item--danger .ee-tablebar__menu-ic {
  color: #dc2626;
}
.ee-tablebar__menu-close {
  grid-column: 1 / -1;
  margin-top: 4px;
  padding: 8px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--editor-muted, #6b7280);
  background: var(--editor-surface-alt, #f9fafb);
  border: 1px solid var(--editor-border, #e5e7eb);
  border-radius: var(--editor-radius-sm, 6px);
  cursor: pointer;
}
.ee-tablebar__menu-close:hover {
  background: var(--editor-hover, #f3f4f6);
  color: var(--editor-text, #1f2937);
}

@media (max-width: 640px) {
  /* No mobile não há barra horizontal longa; o JS mostra apenas o botão flutuante. */
  .ee-tablebar {
    display: none !important;
  }
}

/* ── Tabelas responsivas (rolamento horizontal no celular) ── */
.expert-editor .tableWrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.6em 0;
  max-width: 100%;
}
/* Sem min-width:100% — a tabela pode ENCOLHER ao arrastar a coluna p/ a esquerda
   (senão o espaço liberado é redistribuído nas outras colunas → 'puxa as células').
   Com largura auto + table-layout fixed, a tabela fica com a largura do conteúdo
   e rola horizontalmente no wrapper quando ultrapassa o container. */
.expert-editor .tableWrapper table {
  table-layout: fixed;
  width: auto;
  max-width: 100%;
  border-collapse: collapse;
}
.expert-editor .tableWrapper th,
.expert-editor .tableWrapper td {
  word-break: break-word;
  box-sizing: border-box;
}

/* Dark mode: popover e barra */
[data-theme='dark'] .ee-table-popover,
.dark .ee-table-popover,
[data-theme='dark'] .ee-tablebar,
.dark .ee-tablebar,
[data-theme='dark'] .ee-tablebar__menu,
.dark .ee-tablebar__menu {
  background: var(--editor-surface, #1e293b);
  border-color: rgba(148, 163, 184, 0.2);
}
[data-theme='dark'] .ee-table-grid,
.dark .ee-table-grid {
  background: rgba(15, 23, 42, 0.45);
}
[data-theme='dark'] .ee-table-grid__cell,
.dark .ee-table-grid__cell {
  background: #1e293b;
  border-color: #475569;
}
[data-theme='dark'] .ee-tablebar__btn--danger,
.dark .ee-tablebar__btn--danger {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.4);
}
[data-theme='dark'] .ee-tablebar__btn--danger:hover,
.dark .ee-tablebar__btn--danger:hover {
  background: rgba(248, 113, 113, 0.14);
  color: #fca5a5;
}
[data-theme='dark'] .ee-tablebar__fab,
.dark .ee-tablebar__fab {
  background: var(--editor-surface, #1e293b);
  border-color: rgba(148, 163, 184, 0.2);
  color: #60a5fa;
}
[data-theme='dark'] .ee-tablebar__menu-item:hover,
.dark .ee-tablebar__menu-item:hover {
  background: var(--editor-hover, #334155);
}
[data-theme='dark'] .ee-tablebar__menu-close,
.dark .ee-tablebar__menu-close {
  background: rgba(15, 23, 42, 0.45);
  border-color: rgba(148, 163, 184, 0.2);
}

