/* ============================================================
   EDITOR ACADÊMICO ABNT NBR 14724:2024
   Estilos completos – formato A4 real
   ============================================================ */

/* ---------- RESET & BASE ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --toolbar-h: 54px;
  --sidebar-w: 260px;
  --page-w: 794px;      /* 21cm em 96dpi */
  --page-h: 1123px;     /* 29.7cm em 96dpi */
  --margin-top: 113px;  /* 3cm */
  --margin-left: 113px; /* 3cm */
  --margin-right: 76px; /* 2cm */
  --margin-bottom: 76px;/* 2cm */
  --page-num-offset: 76px; /* 2cm */
  /* Recuo parágrafo ABNT: 1,25cm = ~47.24px em 96dpi */
  --indent-para: 1.25cm;

  /* Cores UI */
  --bg: #e8e8e8;
  --sidebar-bg: #1e2533;
  --sidebar-text: #c8d0e0;
  --toolbar-bg: #1a2035;
  --toolbar-text: #e0e6f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --page-bg: #ffffff;
  --page-shadow: 0 4px 24px rgba(0,0,0,0.18);
  --label-bg: rgba(37,99,235,0.08);
  --label-color: #2563eb;
  --optional-border: #d1d5db;
  --font-body: Arial, 'Liberation Sans', sans-serif;
}

/* Modo Escuro */
body.dark-mode {
  --bg: #111827;
  --sidebar-bg: #0f172a;
  --toolbar-bg: #0f172a;
  --page-bg: #1e293b;
  --page-shadow: 0 4px 24px rgba(0,0,0,0.5);
  --label-bg: rgba(37,99,235,0.15);
}

body.dark-mode .page { color: #e2e8f0; }
body.dark-mode .cover-input { color: #e2e8f0; }
body.dark-mode .cover-institution,
body.dark-mode .cover-author,
body.dark-mode .cover-title,
body.dark-mode .cover-subtitle,
body.dark-mode .cover-volume,
body.dark-mode .cover-city,
body.dark-mode .cover-year { color: #e2e8f0; }
body.dark-mode .editable-content { color: #e2e8f0; }
body.dark-mode .pre-textual-title { color: #e2e8f0; }
body.dark-mode .secao-primaria,
body.dark-mode .secao-secundaria,
body.dark-mode .secao-terciaria,
body.dark-mode .secao-quaternaria { color: #e2e8f0; }
body.dark-mode .nature-text,
body.dark-mode .nature-input,
body.dark-mode .nature-field label { color: #cbd5e1; }
body.dark-mode .ficha-editor { color: #e2e8f0; }
body.dark-mode .ficha-note { color: #94a3b8; }
body.dark-mode .tabela-ibge { color: #e2e8f0; }
body.dark-mode .tabela-ibge thead tr { border-color: #94a3b8; }
body.dark-mode .tabela-titulo,
body.dark-mode .tabela-fonte { color: #e2e8f0; }
body.dark-mode .ilustracao-titulo,
body.dark-mode .ilustracao-fonte { color: #e2e8f0; }
body.dark-mode .citacao-longa { color: #cbd5e1; }
body.dark-mode .apendice-title { color: #e2e8f0; }
body.dark-mode .assinatura-block { color: #e2e8f0; }
body.dark-mode .keywords-block { color: #e2e8f0; }
body.dark-mode .abrev-table { color: #e2e8f0; }
body.dark-mode .sumario-content { color: #e2e8f0; }
body.dark-mode .sumario-dots { border-bottom-color: #475569; }
body.dark-mode .lista-content { color: #e2e8f0; }
body.dark-mode .lista-dots { border-bottom-color: #475569; }
body.dark-mode .epigrafe-text { color: #e2e8f0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: #111;
  min-height: 100vh;
  transition: background 0.3s;
}

/* ---------- TOOLBAR ---------- */
.toolbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--toolbar-h);
  background: var(--toolbar-bg);
  color: var(--toolbar-text);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  z-index: 1000;
  overflow-x: auto;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hamburger-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 5px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.12); }
.hamburger-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: #e0e6f0;
  border-radius: 2px;
  transition: all 0.2s;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 899;
}
.sidebar-overlay.active { display: block; }

.toolbar-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  margin-right: 12px;
  color: #fff;
}
.brand-version { font-weight: 400; font-size: 11px; color: #94a3b8; }
.brand-icon { font-size: 20px; }

.toolbar-groups { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; }

.tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px;
  border-right: 1px solid rgba(255,255,255,0.1);
}
.tool-group:last-child { border-right: none; }

.tool-btn {
  background: transparent;
  color: var(--toolbar-text);
  border: none;
  padding: 5px 9px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  transition: background 0.15s;
}
.tool-btn:hover { background: rgba(255,255,255,0.12); }
.tool-btn.fmt { min-width: 28px; font-size: 14px; }
.tool-btn.btn-danger { color: #fca5a5; }
.tool-btn.btn-danger:hover { background: rgba(220,38,38,0.25); color: #fecaca; }

.btn-clear-section {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
  transition: background 0.15s, border-color 0.15s;
}
.btn-clear-section:hover { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }

.btn-danger-full {
  width: 100%;
  background: #dc2626;
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-danger-full:hover { background: #b91c1c; }

.tool-select {
  background: rgba(255,255,255,0.08);
  color: var(--toolbar-text);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
}
.tool-select option { background: #1e2533; color: #e0e6f0; }

.stats-group { gap: 6px; }
.stat-badge {
  background: rgba(255,255,255,0.1);
  color: #94a3b8;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  white-space: nowrap;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  position: fixed;
  top: var(--toolbar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  overflow-y: auto;
  padding: 12px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.sidebar-header h3 { font-size: 13px; font-weight: 700; color: #e0e6f0; flex: 1; }
.btn-import-toc { font-size: 11px !important; padding: 3px 7px !important; color: #93c5fd !important; }
.btn-import-toc:hover { color: #fff !important; background: rgba(59,130,246,0.3) !important; }
.btn-refresh {
  background: rgba(255,255,255,0.08);
  border: none;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 14px;
  transition: background 0.15s;
}
.btn-refresh:hover { background: rgba(255,255,255,0.18); color: #fff; }

.toc-content { font-size: 12px; line-height: 1.6; }
.toc-empty { color: #64748b; font-style: italic; font-size: 11px; }

.toc-item { cursor: pointer; padding: 2px 4px; border-radius: 3px; transition: background 0.12s; }
.toc-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.toc-item.level-1 { font-weight: 700; margin-top: 4px; text-transform: uppercase; }
.toc-item.level-2 { padding-left: 4px; }
.toc-item.level-3 { padding-left: 4px; font-size: 11px; }
.toc-item.level-4 { padding-left: 4px; font-size: 11px; color: #94a3b8; }

.sidebar-section h4 { font-size: 11px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.section-nav { display: flex; flex-direction: column; gap: 2px; }
.section-nav-item {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  color: #94a3b8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.12s;
}
.section-nav-item:hover { background: rgba(255,255,255,0.06); color: #e0e6f0; }
.section-nav-item.hidden { opacity: 0.4; text-decoration: line-through; }

/* ---------- MAIN CONTAINER ---------- */
.main-container {
  margin-top: var(--toolbar-h);
  margin-left: var(--sidebar-w);
  padding: 32px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  min-height: calc(100vh - var(--toolbar-h));
}

/* ---------- PÁGINA A4 ---------- */
.page {
  width: var(--page-w);
  min-height: var(--page-h);
  background: var(--page-bg);
  box-shadow: var(--page-shadow);
  position: relative;
  padding: var(--margin-top) var(--margin-right) var(--margin-bottom) var(--margin-left);
  display: flex;
  flex-direction: column;
  page-break-after: always;
  overflow: visible;
}

/* Verso: margens invertidas */
.page-verso {
  padding-left: var(--margin-right);
  padding-right: var(--margin-left);
}

/* ---------- PAGINAÇÃO ---------- */
.page[data-page-num]::after {
  content: attr(data-page-num);
  position: absolute;
  top: 20px;
  right: var(--page-num-offset);
  font-family: var(--font-body);
  font-size: 10pt;
  color: #111;
  z-index: 10;
  pointer-events: none;
}
.page-verso[data-page-num]::after {
  right: auto;
  left: var(--page-num-offset);
}

/* Divisores visuais de página no editor */
.page-break-line {
  position: absolute;
  left: 0; right: 0;
  pointer-events: none;
  z-index: 8;
  margin-top: 6px;
  margin-bottom: 6px;
}
.page-break-line::before {
  content: '';
  display: block;
  border-top: 2px dashed #93c5fd;
  width: 100%;
}
.page-break-line-label {
  position: absolute;
  right: 8px;
  top: 3px;
  font-size: 9px;
  color: #3b82f6;
  background: var(--page-bg);
  padding: 0 6px;
  font-family: var(--font-body);
  border-radius: 3px;
  white-space: nowrap;
}

.page-overflow-num {
  position: absolute;
  font-family: var(--font-body);
  font-size: 10pt;
  color: #111;
  pointer-events: none;
  z-index: 10;
}

.page-margin-band {
  position: absolute;
  left: 0; right: 0;
  pointer-events: none;
  z-index: 7;
  background: var(--page-bg);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: var(--page-num-offset);
  font-family: var(--font-body);
  font-size: 10pt;
  color: #111;
}

@media print {
  .page-overflow-num,
  .page-break-line,
  .page-margin-band { display: none !important; }
  body, html, .main-container, .page {
    overflow: visible !important;
    height: auto !important;
  }
}

/* ---------- SECTION LABEL (editor only) ---------- */
.section-label {
  position: absolute;
  top: 6px; right: 6px;
  background: var(--label-bg);
  color: var(--label-color);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
}

.badge-required { background: #2563eb; color: #fff; border-radius: 3px; padding: 1px 5px; font-size: 9px; }
.badge-optional { background: #6b7280; color: #fff; border-radius: 3px; padding: 1px 5px; font-size: 9px; }
.badge-info { background: #0891b2; color: #fff; border-radius: 3px; padding: 1px 5px; font-size: 9px; }

.btn-remove-section {
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 3px;
  padding: 1px 6px;
  cursor: pointer;
  font-size: 11px;
}
.btn-remove-section:hover { background: #dc2626; }

.optional-section.hidden { display: none !important; }

/* ---------- CAPA ---------- */
.page-cover {
  display: flex;
  flex-direction: column;
  height: var(--page-h);
}

#sec-rosto {
  height: var(--page-h);
}

.cover-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  width: 100%;
}

.cover-zone-top {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.cover-authors-block {
  width: 100%;
  margin-top: 48px;
}

.cover-coauthor-field { margin-top: 2px; }

.cover-zone-middle {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  justify-content: center;
  padding: 24px 0;
}

.cover-zone-bottom {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  justify-content: flex-end;
}

.cover-field { width: 100%; text-align: center; margin-bottom: 4px; }
.cover-spacer { flex: 0 0 60px; }
.cover-spacer-flex { flex: 1; }

.cover-input {
  width: 100%;
  border: none;
  border-bottom: 1px dashed #ccc;
  background: transparent;
  text-align: center;
  font-family: var(--font-body);
  color: #111;
  padding: 4px 0;
  outline: none;
  transition: border-color 0.2s, border-style 0.2s;
}
.cover-input:focus { border-bottom-color: var(--accent); }
.cover-input::placeholder { color: #9ca3af; }
.cover-input.has-value { border-bottom-color: transparent; }

.cover-institution { font-size: 12pt; font-weight: 700; text-transform: uppercase; color: #111; }
.cover-course { font-size: 12pt; font-weight: 700; text-transform: uppercase; color: #111; }
.cover-author { font-size: 12pt; text-transform: uppercase; color: #111; font-weight: normal; }
.cover-title { font-size: 12pt; font-weight: 700; text-transform: uppercase; color: #111; }
.cover-subtitle { font-size: 12pt; text-transform: none; color: #111; }
.cover-volume { font-size: 12pt; text-transform: uppercase; color: #555; }
.cover-city { font-size: 12pt; text-transform: none; color: #111; }
.cover-year { font-size: 12pt; color: #111; }

/* ---------- CONTEÚDO DE PÁGINA ---------- */
.page-content { flex: 1; display: flex; flex-direction: column; }

/* ---------- TÍTULOS PRÉ-TEXTUAIS ---------- */
.pre-textual-title {
  font-family: var(--font-body);
  font-size: 12pt;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 24px;
  color: #111;
}

/* ---------- TÍTULOS DE SEÇÕES NUMERADAS (ABNT NBR 6024) ---------- */
.secao-primaria {
  font-family: var(--font-body);
  font-size: 12pt;
  font-weight: 700;
  text-transform: uppercase;
  text-align: left;
  color: #111;
  margin-top: 0;
  margin-bottom: 24px;
}

.secao-secundaria {
  font-family: var(--font-body);
  font-size: 12pt;
  font-weight: 700;
  text-align: left;
  color: #111;
  margin-top: 24px;
  margin-bottom: 24px;
}

.secao-terciaria {
  font-family: var(--font-body);
  font-size: 12pt;
  font-weight: 700;
  font-style: italic;
  text-align: left;
  color: #111;
  margin-top: 24px;
  margin-bottom: 24px;
}

.secao-quaternaria {
  font-family: var(--font-body);
  font-size: 12pt;
  font-style: italic;
  text-align: left;
  color: #111;
  margin-top: 24px;
  margin-bottom: 24px;
}

/* ---------- TEXTO CORRIDO ---------- */
.editable-content {
  font-family: var(--font-body);
  font-size: 12pt;
  line-height: 1.5;
  color: #111;
  text-align: justify;
  flex: 1;
  outline: none;
  min-height: 60px;
}

/* Parágrafos: recuo de 1,25cm na primeira linha, espaçamento 1,5 */
.editable-content p {
  text-indent: var(--indent-para);
  margin-bottom: 0;
  line-height: 1.5;
}

/* Títulos não devem ter recuo */
.editable-content h1, .editable-content h2, .editable-content h3, .editable-content h4,
.editable-content .secao-primaria, .editable-content .secao-secundaria,
.editable-content .secao-terciaria, .editable-content .secao-quaternaria {
  text-indent: 0 !important;
}

/* ---------- LISTAS (ABNT NBR 6034) ----------
   A ABNT não especifica recuo mínimo para listas mas exige alinhamento consistente.
   Prática padrão: margem-esquerda = recuo do parágrafo (1,25cm), sem text-indent nos itens,
   espaçamento entre linhas 1,5 igual ao texto. */
.editable-content ul,
.editable-content ol {
  margin-left: var(--indent-para); /* 1,25cm — alinhado com o recuo dos parágrafos */
  margin-bottom: 0;
  padding-left: 1em;               /* espaço para o marcador */
  line-height: 1.5;
}

.editable-content ul li,
.editable-content ol li {
  text-indent: 0 !important;       /* sem recuo adicional no item */
  line-height: 1.5;
  margin-bottom: 0;
}

/* Listas com bullet quadrado */
.editable-content ul[style*="square"] li,
ul[style*="square"] li { list-style-type: square; }

/* Lista com setas */
.arrow-list { list-style-type: none !important; padding-left: 0; }
.arrow-list li { padding-left: 1.5em; position: relative; }
.arrow-list li::before {
  content: '➔';
  position: absolute;
  left: 0;
  color: inherit;
}

/* Focus visual */
.editable-content:focus {
  box-shadow: inset 0 0 0 1px rgba(37,99,235,0.2);
  border-radius: 2px;
}

/* ---------- CONTEÚDO TEXTUAL ---------- */
.textual-content { min-height: 200px; }

/* ---------- CITAÇÃO LONGA (NBR 10520:2023) ----------
   Recuo 4cm margem esquerda, fonte 10pt, espaçamento simples, sem recuo de parágrafo */
.citacao-longa {
  margin: 12px 0 12px 4cm;
  font-size: 10pt;
  line-height: 1.0;
  text-align: justify;
  color: #111;
  text-indent: 0 !important;
}
.citacao-longa p { text-indent: 0 !important; line-height: 1.0; }

/* ---------- NOTA DE RODAPÉ ---------- */
.rodape-area {
  border-top: 1px solid #ccc;
  margin-top: auto;
  padding-top: 6px;
  font-size: 10pt;
  line-height: 1.0;
}
.rodape-item {
  margin-bottom: 3px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  position: relative;
}
.rodape-item:hover .btn-del-rodape { opacity: 1; }
.rodape-texto {
  flex: 1;
  outline: none;
  border-bottom: 1px dashed transparent;
  min-width: 0;
}
.rodape-texto:focus {
  border-bottom-color: var(--accent);
  background: rgba(37,99,235,0.04);
  border-radius: 2px;
}
.btn-del-rodape {
  opacity: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: #ef4444;
  font-size: 11px;
  padding: 0 2px;
  line-height: 1;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.footnote-ref {
  cursor: default;
  user-select: none;
}

/* ---------- ILUSTRAÇÃO ---------- */
.ilustracao-block {
  margin: 16px 0;
  page-break-inside: avoid;
  break-inside: avoid;
  text-align: center;
}
.ilustracao-inner {
  display: inline-block;
  width: max-content;
  max-width: 100%;
  text-align: left;
}
.ilustracao-titulo {
  font-size: 10pt;
  text-align: center;
  color: #111;
  margin: 0 0 8px 0;
  font-family: var(--font-body);
  font-weight: 700;
}
.ilustracao-img { display: block; max-width: 100%; border: 1px solid #ddd; }
.ilustracao-img-placeholder {
  width: 100%; min-height: 200px; background: #f1f5f9;
  border: 2px dashed #cbd5e1; display: flex; align-items: center;
  justify-content: center; color: #94a3b8; font-size: 11px;
}
.ilustracao-fonte {
  font-size: 10pt; color: #111; margin: 6px 0 0 0;
  font-family: var(--font-body); text-align: left; font-weight: normal;
}
.ilustracao-nota { font-size: 10pt; color: #555; font-family: var(--font-body); }

/* ---------- TABELA IBGE ---------- */
.tabela-block { margin: 16px 0; page-break-inside: avoid; break-inside: avoid; width: 100%; }
.tabela-titulo {
  font-size: 10pt; text-align: left; color: #111; margin-bottom: 6px;
  font-family: var(--font-body); font-weight: 700; text-transform: uppercase;
}
.tabela-ibge {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-body); font-size: 10pt; color: #111;
}
.tabela-ibge thead tr { border-top: 2px solid #111; border-bottom: 1px solid #111; }
.tabela-ibge tfoot tr { border-top: 2px solid #111; }
.tabela-ibge th, .tabela-ibge td { padding: 4px 8px; text-align: left; vertical-align: top; }
.tabela-ibge th { font-weight: 700; }
.tabela-ibge tbody td { border-bottom: none; }
.tabela-fonte { font-size: 10pt; text-align: left; font-weight: normal; color: #111; margin-top: 4px; font-family: var(--font-body); }

/* ---------- FOLHA DE ROSTO NATUREZA ---------- */
.rosto-nature-block {
  width: 50%; align-self: flex-end;
  font-size: 12pt; line-height: 1.0; color: #111; margin: 20px 0;
}
.nature-text {
  font-family: var(--font-body); font-size: 12pt; line-height: 1.0;
  color: #111; margin-bottom: 8px; outline: none;
}
.nature-text:focus { box-shadow: inset 0 0 0 1px rgba(37,99,235,0.3); }
.nature-field { margin-top: 6px; font-size: 12pt; display: flex; flex-direction: column; gap: 2px; }
.nature-field label { font-size: 10pt; color: #555; }
.nature-input {
  border: none; border-bottom: 1px dashed #bbb; background: transparent;
  font-family: var(--font-body); font-size: 12pt; color: #111;
  padding: 2px 0; outline: none; width: 100%; transition: border-color 0.2s;
}
.nature-input:focus { border-bottom-color: var(--accent); }
.nature-input.has-value { border-bottom-color: transparent; }

/* ---------- APROVAÇÃO ---------- */
.aprovacao-wrapper { font-family: var(--font-body); font-size: 12pt; line-height: 1.5; color: #111; }
.aprovacao-autor { text-align: center; font-weight: 700; text-transform: uppercase; margin-bottom: 8px; }
.aprovacao-titulo { text-align: center; font-weight: 700; text-transform: uppercase; margin-bottom: 24px; }
.aprovacao-input-autor { text-align: center !important; font-weight: normal; text-transform: uppercase; font-size: 12pt; width: 100%; }
.aprovacao-titulo-div {
  text-align: center; font-weight: 700; text-transform: uppercase;
  font-size: 12pt; font-family: var(--font-body); line-height: 1.5;
  color: #111; outline: none; width: 100%; word-break: break-word;
  white-space: pre-wrap; min-height: 1.5em; margin-bottom: 24px;
  border-bottom: 1px dashed #ccc; padding-bottom: 2px; transition: border-color 0.2s;
}
.aprovacao-titulo-div:focus { border-bottom-color: var(--accent); }
.aprovacao-titulo-div:not(:empty) { border-bottom-color: transparent; }
.aprovacao-titulo-div[data-placeholder]:empty::before {
  content: attr(data-placeholder); color: #9ca3af; font-weight: 400; text-transform: none; pointer-events: none;
}
.aprovacao-titulo-div .aprov-subtitulo { font-weight: normal; text-transform: none; }
.aprovacao-input-nat { font-size: 12pt; line-height: 1.5; width: 100%; margin-bottom: 4px; text-align: justify; }
.aprovacao-input-data { width: 180px; text-align: center; font-size: 12pt; }
.aprovacao-input-membro { font-weight: 700; font-size: 12pt; width: 100%; text-align: center; }
.aprovacao-input-inst { color: #444; font-size: 12pt; width: 100%; text-align: center; }
.aprovacao-natureza { width: 50%; margin-left: auto; font-size: 12pt; line-height: 1.5; text-align: justify; margin-bottom: 32px; }
.aprovacao-data { text-align: center; margin-bottom: 16px; }
.aprovacao-banca-titulo { text-align: center; font-weight: 700; text-transform: uppercase; margin-bottom: 8px; }
.assinatura-block { margin-top: 32px; text-align: center; }
.assinatura-linha { letter-spacing: 0; margin-bottom: 2px; }
.assinatura-nome { font-weight: 700; margin-bottom: 2px; }
.assinatura-inst { color: #444; margin-bottom: 0; }

body.dark-mode .page-margin-band { background: var(--page-bg); color: #e2e8f0; border-color: #334155 !important; }
body.dark-mode .page-break-line-label { color: #60a5fa; background: var(--page-bg); }
body.dark-mode .assinatura-inst { color: #94a3b8; }
body.dark-mode .aprovacao-input-inst { color: #94a3b8; }
body.dark-mode .aprovacao-titulo-div { color: #e2e8f0; border-bottom-color: #475569; }

/* ---------- DEDICATÓRIA (ABNT: sem título, texto no rodapé, recuo 8cm) ---------- */
#sec-dedicatoria { position: relative; }
.dedicatoria-content { flex: 1; position: relative; min-height: 0; }
.dedicatoria-text {
  position: absolute; bottom: 0;
  left: clamp(120px, 38%, 303px);
  right: 0; line-height: 1.5; font-size: 12pt;
  font-family: var(--font-body); text-align: justify;
  word-break: break-word; overflow-wrap: break-word;
}

@media (max-width: 900px) { .dedicatoria-text { left: clamp(80px, 35%, 260px); } }
@media (max-width: 600px) { .dedicatoria-text { left: clamp(48px, 30%, 160px); font-size: 11pt; } }

/* ---------- EPÍGRAFE (ABNT: sem título, texto no rodapé, recuo 7,5cm, itálico, dir.) ---------- */
#sec-epigrafe { position: relative; }
.epigrafe-content { flex: 1; position: relative; min-height: 0; }
.epigrafe-text {
  position: absolute; bottom: 0;
  left: clamp(110px, 36%, 284px);
  right: 0; line-height: 1.5; font-size: 12pt;
  font-family: var(--font-body); text-align: right; font-style: italic;
  word-break: break-word; overflow-wrap: break-word;
}
.epigrafe-autor { text-align: right; font-style: normal; font-size: 12pt; font-family: var(--font-body); text-indent: 0 !important; margin-top: 4px; }

/* ---------- RESUMO (espaçamento simples, sem recuo) ---------- */
.resumo-text { line-height: 1.0; }
.resumo-text p { text-indent: 0 !important; line-height: 1.0; }
.keywords-block { margin-top: 16px; font-size: 12pt; line-height: 1.5; }
.keywords-input { display: inline; text-align: left !important; font-size: 12pt; font-weight: normal; width: calc(100% - 140px); vertical-align: baseline; }

/* ---------- PLACEHOLDER para contenteditable ---------- */
[contenteditable].has-placeholder:empty::before {
  content: attr(data-placeholder); color: #aaa; font-style: italic;
  pointer-events: none; white-space: pre-wrap;
}
[contenteditable].has-placeholder:focus::before { display: none; }
p.has-placeholder:empty::before {
  content: attr(data-placeholder); color: #aaa; font-style: italic;
  pointer-events: none; display: block;
}
h1.has-placeholder:empty::before,
h1.has-placeholder.placeholder-active::before {
  content: attr(data-placeholder); color: #aaa; font-weight: 700;
  text-transform: uppercase; pointer-events: none;
}

body.dark-mode [contenteditable].has-placeholder:empty::before,
body.dark-mode p.has-placeholder:empty::before,
body.dark-mode h1.has-placeholder:empty::before { color: #64748b; }

.insert-cursor-zone { position: relative; outline: 2px dashed var(--accent); outline-offset: 2px; border-radius: 2px; }
.insert-cursor-zone::after {
  content: '⬅ Inserção aqui'; position: absolute; right: 0; top: 0;
  font-size: 9px; color: var(--accent); background: rgba(37,99,235,0.08);
  padding: 1px 5px; border-radius: 0 0 0 4px; pointer-events: none;
  font-family: var(--font-body); border-radius: 3px; white-space: nowrap;
}

/* ---------- FICHA CATALOGRÁFICA ---------- */
.ficha-content { justify-content: flex-end; }
.ficha-box {
  border: 1px solid #111; padding: 10px 14px;
  font-family: 'Times New Roman', Arial, serif; font-size: 11pt; line-height: 1.2;
  text-align: justify; width: min(12.5cm, 100%); height: 7.5cm;
  overflow: hidden; margin: 0 auto; box-sizing: border-box;
}
.ficha-editor {
  font-family: 'Times New Roman', Arial, serif; font-size: 11pt; line-height: 1.2;
  text-align: justify; outline: none; white-space: pre-wrap; overflow: hidden; height: 100%;
}
.ficha-note { font-size: 9pt; text-align: center; margin-top: 8px; color: #555; outline: none; border-bottom: 1px dashed transparent; transition: border-color 0.2s; }
.ficha-note:focus { border-bottom-color: var(--accent); }
body.dark-mode .ficha-note { color: #94a3b8; }
body.dark-mode .ficha-box { border-color: #475569; color: #e2e8f0; }
body.dark-mode .ficha-editor { color: #e2e8f0; }

/* ---------- SUMÁRIO (NBR 6027) ----------
   Sem recuo — hierarquia apenas por tipografia */
.sumario-content { font-size: 12pt; }
.sumario-item {
  display: flex; align-items: flex-end; margin-bottom: 6px;
  font-family: var(--font-body); cursor: pointer; transition: color 0.15s;
}
.sumario-item:hover { color: var(--accent); }
.sumario-item.nivel-1 { font-weight: 700; text-transform: uppercase; }
.sumario-item.nivel-2 { font-weight: 700; text-transform: none; }
.sumario-item.nivel-3 { font-style: italic; font-weight: 400; }
.sumario-item.nivel-4 { font-style: italic; font-weight: 400; }
.sumario-dots { flex: 1; border-bottom: 1px dotted #999; margin: 0 6px 3px; }
.sumario-page { white-space: nowrap; }

/* ---------- LISTA ---------- */
.lista-content { font-size: 12pt; }
.lista-item { display: flex; align-items: flex-end; margin-bottom: 6px; font-family: var(--font-body); }
.lista-dots { flex: 1; border-bottom: 1px dotted #999; margin: 0 6px 3px; }
.lista-empty { color: #9ca3af; font-size: 11px; font-style: italic; }

/* ---------- ABREVIATURAS ---------- */
.abrev-table { width: 100%; border-collapse: collapse; font-size: 12pt; }
.abrev-table td { padding: 3px 0; vertical-align: top; }
.abrev-sigla { width: 120px; font-weight: 700; }

/* ---------- ERRATA ---------- */
.errata-table {
  border-collapse: collapse; font-size: 12pt; margin-top: 12px;
  width: 100%; table-layout: fixed;
}
.errata-table th, .errata-table td {
  border: 1px solid #111; padding: 8px 10px;
  vertical-align: middle; word-break: break-word; overflow-wrap: break-word;
}
.errata-table th:nth-child(1), .errata-table td:nth-child(1) { width: 12%; }
.errata-table th:nth-child(2), .errata-table td:nth-child(2) { width: 12%; }
.errata-table th:nth-child(3), .errata-table td:nth-child(3) { width: 35%; }
.errata-table th:nth-child(4), .errata-table td:nth-child(4) { width: 35%; }
.errata-table th:nth-child(5), .errata-table td:nth-child(5) { width: 6%; }
.errata-table tbody td { min-height: 36px; height: 36px; line-height: 1.5; }
.errata-table td[contenteditable="true"] { cursor: text; }
.errata-table th { background: #f1f5f9; font-weight: 700; }

.btn-del-errata-row {
  background: #fee2e2; color: #dc2626; border: none; border-radius: 3px;
  padding: 2px 6px; cursor: pointer; font-size: 11px; transition: background 0.15s;
}
.btn-del-errata-row:hover { background: #fca5a5; }
.errata-referencia { text-indent: 0 !important; text-align: left !important; line-height: 1 !important; margin-bottom: 12px; }
body.dark-mode .errata-table th { background: #2d3f55; color: #e2e8f0; }
body.dark-mode .errata-table th, body.dark-mode .errata-table td { border-color: #475569; color: #e2e8f0; }

/* ---------- REFERÊNCIAS (NBR 6023:2025 — espaço simples, sem recuo, 1 linha entre entradas) ---------- */
.referencias-lista { display: flex; flex-direction: column; gap: 0; }
.ref-item { display: flex; align-items: flex-start; gap: 6px; position: relative; }
.ref-texto {
  flex: 1; font-family: var(--font-body); font-size: 12pt;
  line-height: 1.0; text-align: left; text-indent: 0 !important;
  margin-bottom: 1em; outline: none; min-height: 1.2em;
  border-bottom: 1px dashed transparent; transition: border-color 0.2s;
}
.ref-texto:focus { border-bottom-color: rgba(37,99,235,0.3); }
.btn-del-ref {
  background: #fee2e2; color: #dc2626; border: none; border-radius: 3px;
  padding: 2px 6px; cursor: pointer; font-size: 11px; flex-shrink: 0;
  margin-top: 2px; transition: background 0.15s;
}
.btn-del-ref:hover { background: #fca5a5; }

/* ---------- LISTAS EDITÁVEIS ---------- */
.lista-editavel { display: flex; flex-direction: column; gap: 0; }
.lista-row {
  display: flex; align-items: center; gap: 8px; padding: 3px 0;
  border-bottom: 1px solid transparent; transition: border-color 0.15s;
}
.lista-row:hover { border-bottom-color: #e5e7eb; }
.lista-col-sigla {
  width: 130px; flex-shrink: 0; font-family: var(--font-body); font-size: 12pt; font-weight: 700;
  color: #111; border: none; border-bottom: 1px dashed #ccc; background: transparent;
  outline: none; padding: 2px 4px; transition: border-color 0.2s;
}
.lista-col-sigla:focus { border-bottom-color: var(--accent); }
.lista-col-desc {
  flex: 1; font-family: var(--font-body); font-size: 12pt; color: #111;
  border: none; border-bottom: 1px dashed #ccc; background: transparent;
  outline: none; padding: 2px 4px; transition: border-color 0.2s;
}
.lista-col-desc:focus { border-bottom-color: var(--accent); }
.btn-del-row {
  background: #fee2e2; color: #dc2626; border: none; border-radius: 3px;
  padding: 2px 6px; cursor: pointer; font-size: 11px; flex-shrink: 0; transition: background 0.15s;
}
.btn-del-row:hover { background: #fca5a5; }
.lista-add-bar { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.btn-add-row {
  background: var(--accent); color: #fff; border: none; padding: 7px 14px;
  border-radius: 6px; cursor: pointer; font-size: 12px; font-family: var(--font-body); transition: background 0.15s;
}
.btn-add-row:hover { background: var(--accent-hover); }
.btn-add-row-sec { background: #6b7280; }
.btn-add-row-sec:hover { background: #4b5563; }

body.dark-mode .lista-col-sigla,
body.dark-mode .lista-col-desc,
body.dark-mode .ref-texto { color: #e2e8f0; border-bottom-color: #475569; }
body.dark-mode .btn-del-row,
body.dark-mode .btn-del-ref { background: #7f1d1d; color: #fca5a5; }
body.dark-mode .lista-row:hover { border-bottom-color: #334155; }

/* ---------- APÊNDICE / ANEXO ---------- */
.apendice-title {
  font-size: 12pt; font-weight: 700; text-transform: uppercase;
  text-align: center; color: #111; margin-bottom: 24px;
}

/* ---------- BOTÕES ---------- */
.btn-add-ref {
  background: var(--accent); color: #fff; border: none; padding: 8px 16px;
  border-radius: 6px; cursor: pointer; font-size: 12px; font-family: var(--font-body);
}
.btn-add-ref:hover { background: var(--accent-hover); }

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  z-index: 2000; display: none; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: #fff; border-radius: 10px; box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  width: 480px; max-width: 95vw; max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column;
}
.modal-box-lg { width: 640px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #e5e7eb; }
.modal-header h3 { font-size: 15px; font-weight: 700; color: #111; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: #6b7280; transition: color 0.15s; }
.modal-close:hover { color: #111; }
.modal-close-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: #6b7280; transition: color 0.15s; }
.modal-close-btn:hover { color: #111; }
.modal-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.modal-body label { font-size: 12px; font-weight: 600; color: #374151; }
.modal-insert-hint { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 6px; padding: 8px 12px; font-size: 12px; color: #1e40af; line-height: 1.5; margin-bottom: 4px; }
.modal-input { width: 100%; border: 1px solid #d1d5db; border-radius: 6px; padding: 8px 10px; font-size: 13px; font-family: var(--font-body); outline: none; transition: border-color 0.15s; }
.modal-input:focus { border-color: var(--accent); }
.modal-footer { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid #e5e7eb; justify-content: flex-end; }
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 8px 20px; border-radius: 6px; cursor: pointer; font-size: 13px; font-family: var(--font-body); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; font-family: var(--font-body); }
.btn-secondary:hover { background: #e5e7eb; }
.ref-preview { margin-top: 8px; }
.ref-preview label { font-size: 12px; font-weight: 600; color: #374151; }
.ref-preview-text { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 10px 12px; font-size: 12px; line-height: 1.5; min-height: 60px; color: #111; font-family: var(--font-body); }

/* ---------- NOTIFICAÇÃO ---------- */
.notification {
  position: fixed; bottom: 24px; right: 24px; background: #111827; color: #fff;
  padding: 12px 20px; border-radius: 8px; font-size: 13px; z-index: 9999;
  opacity: 0; transform: translateY(16px); transition: opacity 0.3s, transform 0.3s; pointer-events: none;
}
.notification.show { opacity: 1; transform: translateY(0); }
.notification.success { background: #059669; }
.notification.error { background: #dc2626; }
.notification.warning { background: #f59e0b; }

/* ============================================================
   IMPRESSÃO / PDF
   ============================================================ */
@media print {
  @page {
    size: A4;
    margin: 3cm 2cm 2cm 3cm;
  }

  body { background: #fff; font-family: Arial, sans-serif; }

  .no-print,
  .toolbar,
  .sidebar,
  .section-label,
  .btn-remove-section,
  .btn-add-ref,
  .notification,
  .page-overflow-num,
  .page-break-line,
  .page-margin-band { display: none !important; }

  /* Notas de rodapé: remove UI de edição na impressão */
  .rodape-texto { border-bottom: none !important; background: none !important; }
  .rodape-item { display: block !important; }

  .main-container {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .page {
    width: 100%;
    min-height: 0;
    padding: 0 !important;
    box-shadow: none;
    page-break-before: always;
    break-before: page;
    page-break-inside: auto;
    break-inside: auto;
    overflow: visible;
  }

  .page-cover { page-break-before: always; break-before: page; }
  .page-cover,
  #sec-rosto:not(.hidden) {
    display: flex !important;
    flex-direction: column !important;
    height: 23.7cm !important;
    min-height: 0 !important;
  }
  .page-cover .cover-content,
  #sec-rosto .cover-content {
    display: flex !important; flex-direction: column !important;
    flex: 1 !important; height: 100% !important; width: 100% !important; align-items: center !important;
  }
  .cover-zone-top, .cover-zone-middle, .cover-zone-bottom { flex: 1 !important; width: 100% !important; }
  .cover-zone-middle { justify-content: center !important; }
  .cover-zone-bottom { justify-content: flex-end !important; }
  .cover-spacer-flex { flex: 1 !important; }
  .page-verso { padding-left: 0 !important; padding-right: 0 !important; }
  .optional-section.hidden { display: none !important; }

  #sec-rosto.hidden, #sec-aprovacao.hidden, #sec-resumo.hidden,
  #sec-abstract.hidden, #sec-sumario.hidden, #sec-referencias.hidden { display: none !important; }

  .editable-content:focus { box-shadow: none; }
  [data-print-hidden="true"] { display: none !important; }
  #textualArea { display: block !important; }

  .cover-input, .nature-input, .keywords-input,
  .lista-col-sigla, .lista-col-desc, .ref-texto { border-bottom: none !important; }

  .btn-del-row, .btn-del-ref, .btn-del-errata-row, .btn-add-row, .lista-add-bar { display: none !important; }
  .aprovacao-input-autor, .aprovacao-input-nat, .aprovacao-input-data,
  .aprovacao-input-membro, .aprovacao-input-inst, .aprovacao-titulo-div { border-bottom: none !important; }
  .aprovacao-titulo-div[data-placeholder]:empty::before { display: none !important; }
  [contenteditable].has-placeholder:empty::before,
  p.has-placeholder:empty::before,
  h1.has-placeholder:empty::before { display: none !important; }
  .insert-cursor-zone::after { display: none !important; }
  .insert-cursor-zone { outline: none !important; }

  /* ── NUMERAÇÃO NA IMPRESSÃO (ABNT NBR 14724:2024) ──────────────────────
     Capa  → counter-reset:0 → não conta (vale 0)
     Ficha → counter-reset:0 novamente → também não conta
     Pré-textuais → contam, sem exibir número (semnum)
     Textuais → contam e exibem número (@page padrão)
  ──────────────────────────────────────────────────────────────────────── */
  @page capa {
    counter-reset: page 0;
    @top-right { content: none; }
  }
  @page ficha {
    counter-reset: page 0;
    @top-right { content: none; }
  }
  @page semnum { @top-right { content: none; } }
  @page {
    @top-right {
      content: counter(page);
      font-family: Arial, sans-serif;
      font-size: 10pt;
      color: #000;
    }
  }
  .page-cover { page: capa; }
  #sec-ficha { page: ficha; }
  #sec-ficha .page-content {
    display: flex !important; flex-direction: column !important;
    justify-content: flex-end !important; height: 100% !important; min-height: 23.7cm !important;
  }
  #sec-ficha .ficha-box {
    width: 12.5cm !important; height: 7.5cm !important;
    min-height: unset !important; overflow: hidden !important; margin: 0 auto !important;
  }

  #sec-rosto, #sec-errata, #sec-aprovacao, #sec-dedicatoria,
  #sec-agradecimentos, #sec-epigrafe, #sec-resumo, #sec-abstract,
  #sec-listailustracoes, #sec-listatabelas, #sec-abreviaturas,
  #sec-simbolos, #sec-sumario { page: semnum; }

  .page[data-page-num]::after { display: none !important; }

  .cover-input:placeholder-shown { display: none !important; }
  .cover-volume-field:has(input:placeholder-shown) { display: none !important; }
  .cover-field:has(#coverSubtitle:placeholder-shown),
  .cover-field:has(#rostoSubtitle:placeholder-shown) { display: none !important; }

  #textualArea .page.textual-page,
  #textualArea > .page {
    display: block !important;
    page-break-before: always !important;
    break-before: page !important;
    page-break-after: auto !important;
    break-after: auto !important;
    page-break-inside: auto !important;
    break-inside: auto !important;
  }

  #textualArea .page.textual-page h1.secao-primaria,
  h1.secao-primaria {
    page-break-before: avoid !important;
    break-before: avoid !important;
    margin-top: 0;
  }

  h2.secao-secundaria, h3.secao-terciaria, h4.secao-quaternaria {
    page-break-before: auto; break-before: auto;
    page-break-after: avoid; break-after: avoid;
    page-break-inside: avoid; break-inside: avoid;
  }

  .errata-table { display: table !important; width: 100% !important; table-layout: fixed !important; overflow: visible !important; }

  #sec-dedicatoria { position: relative !important; }
  .dedicatoria-content { position: relative !important; flex: 1 !important; min-height: 0 !important; }
  .dedicatoria-text {
    position: absolute !important; bottom: 0 !important;
    left: 8cm !important; right: 0 !important;
    line-height: 1.5 !important; font-size: 12pt !important; text-align: justify !important;
  }

  #sec-epigrafe { position: relative !important; }
  .epigrafe-content { position: relative !important; flex: 1 !important; min-height: 0 !important; }
  .epigrafe-text {
    position: absolute !important; bottom: 0 !important;
    left: 7.5cm !important; right: 0 !important;
    line-height: 1.5 !important; font-size: 12pt !important; text-align: right !important;
  }
  .epigrafe-autor { text-align: right !important; font-size: 12pt !important; }

  /* Listas na impressão: mantém recuo 1,25cm e espaçamento 1,5 */
  .editable-content ul, .editable-content ol {
    margin-left: 1.25cm !important;
    line-height: 1.5 !important;
  }
  .editable-content ul li, .editable-content ol li {
    line-height: 1.5 !important;
  }
}

/* ---------- RESPONSIVIDADE ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; z-index: 900; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.4); }
  .main-container { margin-left: 0; padding: 16px; }
  .page { width: 100%; max-width: var(--page-w); box-sizing: border-box; overflow-x: hidden; }
  .errata-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .lista-row { flex-wrap: wrap; gap: 4px; }
  .lista-col-sigla { width: 100px; min-width: 60px; flex-shrink: 1; }
  .lista-col-desc { flex: 1; min-width: 0; }
  .ref-item { flex-wrap: wrap; }
  .lista-add-bar { flex-wrap: wrap; gap: 6px; }
}

@media (max-width: 600px) {
  .toolbar { flex-wrap: wrap; height: auto; padding: 6px; }
  .page { padding: 32px 14px 16px 14px; box-sizing: border-box; }
  .lista-col-sigla { width: 80px; }
  .errata-table th, .errata-table td { font-size: 10pt; padding: 4px; }
}

@media (max-width: 480px) {
  .errata-table th, .errata-table td {
    font-size: 8.5pt; padding: 3px;
    hyphens: auto; -webkit-hyphens: auto;
    word-break: break-word; overflow-wrap: break-word;
  }
}

/* ============================================================
   MODAL DE SÍMBOLOS E FÓRMULAS MATEMÁTICAS
   ============================================================ */
.math-modal-box { max-width: 720px; width: 95vw; max-height: 85vh; display: flex; flex-direction: column; }
.math-modal-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 12px 16px 0; border-bottom: 1px solid #e5e7eb; background: #f8fafc; }
body.dark-mode .math-modal-tabs { background: #1e293b; border-bottom-color: #334155; }
.math-tab { background: transparent; border: none; padding: 6px 14px; font-size: 12px; font-weight: 500; color: #64748b; cursor: pointer; border-radius: 6px 6px 0 0; transition: all 0.15s; border-bottom: 3px solid transparent; }
.math-tab:hover { background: rgba(37,99,235,0.07); color: #2563eb; }
.math-tab.active { color: #2563eb; border-bottom-color: #2563eb; background: rgba(37,99,235,0.06); font-weight: 600; }
.math-tab-content { display: none; padding: 14px 16px; overflow-y: auto; flex: 1; }
.math-tab-content.active { display: block; }
.math-section-label { font-size: 11px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; margin: 10px 0 6px; }
.math-section-label:first-child { margin-top: 0; }
.math-symbols-grid { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 4px; }
.sym-btn {
  min-width: 44px; height: 40px; padding: 4px 8px;
  background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 6px;
  font-size: 15px; font-family: 'Times New Roman', Georgia, serif;
  cursor: pointer; color: #1e293b; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.sym-btn:hover { background: #2563eb; color: #fff; border-color: #2563eb; transform: scale(1.08); box-shadow: 0 2px 8px rgba(37,99,235,0.3); }
body.dark-mode .sym-btn { background: #1e293b; border-color: #334155; color: #e2e8f0; }
body.dark-mode .sym-btn:hover { background: #2563eb; color: #fff; border-color: #2563eb; }

.math-formulas-list { display: flex; flex-direction: column; gap: 6px; }
.formula-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 14px; background: #f8fafc; border: 1px solid #e2e8f0;
  border-left: 3px solid #2563eb; border-radius: 6px; cursor: pointer;
  text-align: left; transition: all 0.15s; width: 100%;
}
.formula-btn:hover { background: #eff6ff; border-color: #2563eb; border-left-color: #1d4ed8; box-shadow: 0 2px 8px rgba(37,99,235,0.15); }
.formula-name { font-size: 11px; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: 0.03em; }
.formula-expr { font-family: 'Times New Roman', Georgia, serif; font-size: 15px; color: #1e293b; font-style: italic; }
body.dark-mode .formula-btn { background: #1e293b; border-color: #334155; }
body.dark-mode .formula-btn:hover { background: #172554; border-color: #2563eb; }
body.dark-mode .formula-expr { color: #e2e8f0; }
body.dark-mode .formula-name { color: #94a3b8; }

.math-modal-footer { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid #e5e7eb; background: #f8fafc; border-radius: 0 0 10px 10px; flex-shrink: 0; }
body.dark-mode .math-modal-footer { background: #1e293b; border-top-color: #334155; }
.math-hint { font-size: 12px; color: #94a3b8; }

/* ---------- ESTRUTURAS MATEMÁTICAS ---------- */
.math-structure { display: inline-flex; vertical-align: middle; align-items: center; margin: 0 2px; line-height: 1.1; font-family: var(--font-body); position: relative; text-indent: 0; width: fit-content; }
.math-frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; padding: 0 2px; line-height: 1.1; min-width: 0.8em; }
.math-frac-num { border-bottom: 1px solid currentColor; padding: 0 4px; text-align: center; font-size: 0.85em; width: 100%; box-sizing: border-box; display: inline-block; outline: none; min-width: 1ch; }
.math-frac-den { padding: 0 4px; text-align: center; font-size: 0.85em; width: 100%; box-sizing: border-box; display: inline-block; outline: none; min-width: 1ch; }
.math-frac-num:empty::before, .math-frac-den:empty::before { content: '\00a0'; }
.math-limits { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1; margin: 0 4px; }
.math-limit-sup { font-size: 0.65em; min-height: 0.8em; text-align: center; width: 100%; display: block; outline: none; }
.math-limit-op { font-size: 1.4em; line-height: 0.9; padding: 1px 0; user-select: none; }
.math-limit-sub { font-size: 0.65em; min-height: 0.8em; text-align: center; width: 100%; display: block; outline: none; }
.math-binom { display: inline-flex; align-items: center; vertical-align: middle; padding: 0 2px; line-height: 1; }
.math-binom-paren { font-size: 1.8em; font-weight: 300; transform: scaleY(1.3); }
.math-binom-content { display: inline-flex; flex-direction: column; align-items: center; padding: 0 2px; font-size: 0.85em; }
.math-binom-content span { display: block; width: 100%; text-align: center; outline: none; }
body.dark-mode .math-frac-num { border-bottom-color: #e2e8f0; }
.math-sqrt { display: inline-flex; align-items: center; vertical-align: middle; line-height: 1; }
.math-sqrt-sym { font-size: 1.2em; margin-right: -2px; transform: scaleY(1.2); }
.math-sqrt-content { border-top: 1px solid currentColor; padding: 2px 2px 0 2px; font-size: 0.9em; min-width: 1ch; outline: none; }
