@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* Mapeamento conservador para os tokens oficiais Tá Bonito (assets/brand/tokens.css) */
:root,
html[data-theme="light"],
html[data-theme="dark"],
html[data-contrast="high"] {
  --bg-shell: var(--bg-sidebar);
  --bg-surface: var(--bg-elevated);
  --bg-canvas: var(--bg-desk);
  --border: var(--line);
  --border-strong: var(--line-strong);
  --text-primary: var(--text-1);
  --text-secondary: var(--text-2);
  --text-muted: var(--text-3);
  --ok: var(--ok-solid);
  --warn: var(--warn-solid);
  --danger: var(--err-solid);
  --radius: 8px;
}

/* Alto Contraste (somente na tela — nunca altera Arial 12 branco/preto na exportação) */
html[data-contrast="high"] {
  letter-spacing: 0.015em;
}
html[data-contrast="high"] #wordcraft_canvas {
  filter: contrast(1.16);
}

/* Seleção e foco com o acento marca-texto contido (#DDF247 / --accent-soft) */
::selection {
  background: var(--accent-soft);
  color: var(--on-soft);
}
:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-halo), 0 0 0 4px var(--focus-ring);
}

/* Troca instantânea das logos por tema */
.logo-dark { display: none; }
html[data-theme="dark"] .logo-light { display: none; }
html[data-theme="dark"] .logo-dark { display: block; }

/* Números tabulares e códigos técnicos em JetBrains Mono */
code,
#audit-score-text,
#word-count-badge,
#resumo-word-count,
#count-spelling,
#count-style,
.mode-badge,
.lint-tag {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-shell);
  -webkit-font-smoothing: antialiased;
}

body[data-view="landing"] #view-workspace {
  position: fixed;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}
body[data-view="workspace"] {
  overflow: hidden;
}
body[data-view="workspace"] #view-landing {
  display: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
}

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary, .icon-btn, .link-btn, .mini-action, .chip-btn {
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  border: var(--border-w) solid var(--btn-primary-bg);
  padding: 9px 16px;
  font-weight: 500;
}
.btn-primary:hover:not(:disabled) { background: var(--btn-primary-bg-hover); border-color: var(--btn-primary-bg-hover); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: var(--border-w) solid var(--border);
  padding: 8px 14px;
  font-weight: 500;
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-full { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.link-btn {
  background: none;
  border: none;
  padding: 2px 4px;
  color: var(--text-muted);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--text-primary); }

/* =========================================================
   ESTADO 1: LANDING / CONVERSOR RÁPIDO + GUIA SEO
   ========================================================= */
.landing-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-shell);
}

.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo-h {
  height: 24px;
  width: auto;
  display: block;
}
.hero-brand-mark {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}
.hero-logo {
  width: 176px;
  height: auto;
}
.tb-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  flex-shrink: 0;
}
.tb-back-label {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pill-local {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-shell);
  font-size: 12px;
  color: var(--text-secondary);
}

.landing-main {
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 20px 56px;
}

.hero { text-align: center; }
.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(24px, 3.6vw, 34px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
}
.hero-lead {
  max-width: 640px;
  margin: 0 auto 28px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.converter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: left;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.mode-btn {
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-shell);
  cursor: pointer;
}
.mode-btn strong { display: block; font-size: 13.5px; margin-bottom: 3px; }
.mode-btn span { display: block; font-size: 11.5px; color: var(--text-muted); line-height: 1.35; }
.mode-btn.active {
  background: var(--bg-surface);
  border-color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--text-primary);
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--bg-shell);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--text-primary);
  background: var(--bg-hover);
}
.drop-icon { color: var(--text-muted); }
.drop-copy strong { display: block; font-size: 14px; margin-bottom: 3px; }
.drop-copy span { font-size: 12px; color: var(--text-muted); }

.converter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}
.secondary-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.engine-status {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Guia Rápido ABNT SEO */
.seo-guide { margin-top: 32px; }
.guide-accordion {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.guide-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  cursor: pointer;
}
.guide-summary::-webkit-details-marker { display: none; }
.guide-summary h2 { margin: 0 0 3px; font-size: 15.5px; font-weight: 600; }
.guide-summary p { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.guide-accordion[open] .chevron { transform: rotate(180deg); }
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  padding: 0 22px 22px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.guide-card {
  background: var(--bg-shell);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.guide-card h3 { margin: 0 0 6px; font-size: 13.5px; font-weight: 600; }
.guide-card p { margin: 0; font-size: 12.5px; color: var(--text-secondary); line-height: 1.55; }

.legal-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  padding: 16px 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.legal-links { display: flex; flex-wrap: wrap; gap: 12px; }
.legal-note { font-size: 11.5px; color: var(--text-muted); }

/* =========================================================
   PARTE 2 & 3: EDITOR DESCOMPLICADO (DESKTOP + MOBILE <= 820px)
   Sem rail estreito de ícones; barra superior única 56px; 3 abas grandes
   ========================================================= */
.workspace-shell {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-shell);
}
.workspace-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr) 336px;
  overflow: hidden;
}
.workspace-shell.left-collapsed .workspace-body {
  grid-template-columns: 0px minmax(0, 1fr) 336px;
}
.workspace-shell.left-collapsed .sidebar-left {
  display: none;
}

.sidebar-left, .sidebar-right {
  background: var(--bg-shell);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.sidebar-left { border-right: 1px solid var(--border); }
.sidebar-right { border-left: 1px solid var(--border); }

/* Barra Superior Única (56px desktop) */
.editor-topbar {
  height: 56px;
  flex-shrink: 0;
  padding: 0 14px;
  background: var(--bg-surface);
  border-bottom: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  z-index: 50;
}
.topbar-left,
.topbar-center,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.topbar-left { flex: 1 1 auto; }
.topbar-center { flex: 0 0 auto; }
.topbar-right { flex: 0 0 auto; }

.topbar-brand {
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: none;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
}
.topbar-brand:hover { background: var(--bg-hover); }

.topbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.topbar-btn:hover { background: var(--bg-hover); border-color: var(--text-primary); }
.topbar-btn[aria-pressed="true"] { background: var(--bg-shell); }

.toc-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text-secondary);
}
.toc-pill.on {
  background: #DDF247;
  color: #0A0A0A;
  border: 1px solid #0A0A0A;
}

.doc-title-input {
  flex: 1 1 140px;
  min-width: 90px;
  max-width: 220px;
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
}
.doc-title-input:hover { border-color: var(--border); background: var(--bg-shell); }
.doc-title-input:focus { outline: none; border-color: var(--text-primary); background: var(--bg-surface); }

.btn-export-highlight {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 9px;
  background: #DDF247;
  color: #0A0A0A;
  border: 1.5px solid #0A0A0A;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-export-highlight:hover { background: #CFE62C; }
.export-label-mobile { display: none; }

/* Popover "Inserir ▾" */
.insert-menu-wrap { position: relative; }
.insert-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 280px;
  max-height: 75vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1.5px solid var(--text-primary);
  border-radius: 12px;
  box-shadow: var(--sh-3);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 90;
}
.popover-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.popover-item:hover { background: var(--bg-hover); }
.popover-item strong { font-size: 13.5px; color: var(--text-primary); }
.popover-item span { font-size: 12px; color: var(--text-muted); }
.popover-sep { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* 3 Abas Grandes do Painel Direito (40px altura, ícone + texto) */
.right-tabs-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 8px 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.right-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 40px;
  padding: 6px 6px;
  border: none;
  border-bottom: 2.5px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.right-tab-btn:hover { color: var(--text-primary); background: var(--bg-hover); border-radius: 6px 6px 0 0; }
.right-tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
}
.right-tab-btn strong {
  font-family: var(--font-mono);
  font-size: 12px;
}

.score-big-mono {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}
.meter-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}
.btn-fix-inline {
  min-height: 36px;
  padding: 4px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--text-primary);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-fix-inline:hover {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  border-color: var(--btn-primary-bg);
}

/* Elementos exclusivos do Mobile (ocultos no Desktop) */
.mobile-overlay,
.sidebar-mobile-head,
.sidebar-mobile-shortcuts,
.sheet-mobile-handle,
.sheet-mobile-head,
.mobile-quick-bar,
.mobile-view-bar,
.mobile-bottom-bar,
.mobile-bottom-sheet {
  display: none;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 4px 6px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
}
.btn-back:hover { background: var(--bg-hover); }
.mode-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
}

.sidebar-section {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.drafts-section { flex: 0.85; }
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.muted-count { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11px; color: var(--text-muted); }

.mini-action {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 2px 7px;
  font-size: 11px;
  color: var(--text-secondary);
}
.mini-action:hover { background: var(--bg-hover); color: var(--text-primary); }

.outline-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: block;
}
.drafts-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.outline-item {
  display: block;
  width: 100%;
  min-height: 28px;
  margin-bottom: 2px;
  text-align: left;
  background: transparent;
  border: none;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.outline-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.outline-item.lvl-1 { font-weight: 500; }
.outline-item.lvl-2 { padding-left: 18px; font-size: 12px; }
.outline-item.lvl-3 { padding-left: 28px; font-size: 11.5px; color: var(--text-muted); }

.draft-card {
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.draft-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.draft-card strong {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.draft-card span { font-size: 11px; color: var(--text-muted); }
.draft-card-actions { display: flex; gap: 6px; margin-top: 2px; }

.empty-hint {
  margin: 4px 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.sidebar-footer {
  margin-top: auto;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.tool-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11.5px;
  cursor: pointer;
}
.tool-toggle:hover, .tool-toggle[aria-pressed="true"] {
  background: var(--bg-hover);
  border-color: var(--text-primary);
}

/* Central column */
.workspace-center {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-canvas);
}
.topbar {
  height: 48px;
  padding: 0 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-shell);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  width: 210px;
}
.search-box input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 12.5px;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.mode-select {
  background: var(--bg-shell);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 12px;
}

.canvas-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  background: var(--bg-canvas);
}
#wordcraft_canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.canvas-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
  pointer-events: none;
}

.workspace-legal-strip {
  height: 28px;
  padding: 0 12px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
}
.strip-hint { margin-left: auto; color: var(--text-muted); font-size: 11px; }

/* Right Inspector + 44px Rail */
.inspector-panel {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  overflow-y: auto;
  height: 100%;
}
.inspector-panel.active { display: flex; }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-header h2 { margin: 0; font-size: 13.5px; font-weight: 600; }

.meter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.meter-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 12.5px;
}
.meter-top strong { font-size: 18px; }
.meter-track {
  height: 7px;
  background: var(--bg-hover);
  border-radius: 999px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  background: var(--ok);
  transition: width 0.25s ease;
}
.meter-sub { margin: 7px 0 0; font-size: 11.5px; color: var(--text-muted); }

.panel-block h3 {
  margin: 0 0 6px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.block-hint { margin: 0 0 8px; font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

.checks-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.check-item {
  flex-shrink: 0;
  background: var(--bg-surface);
  border: var(--border-w) solid var(--border);
  border-radius: 6px;
  padding: 8px 9px;
  font-size: 12px;
}
.check-item.is-ok { border-left: 3px solid var(--ok-solid); }
.check-item.is-warn { border-left: 3px solid var(--warn-solid); background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-fg); }
.check-item.is-err { border-left: 3px solid var(--err-solid); background: var(--err-bg); border-color: var(--err-border); color: var(--err-fg); }
.check-item.is-warn .check-detail { color: var(--warn-fg); opacity: 0.9; }
.check-item.is-err .check-detail { color: var(--err-fg); opacity: 0.9; }
.check-item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  margin-bottom: 2px;
}
.check-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.check-icon.ok { background: var(--ok-bg); color: var(--ok-fg); }
.check-icon.warn { background: var(--warn-solid); color: #FFFFFF; }
.check-icon.err { background: var(--err-solid); color: #FFFFFF; }
.check-detail { font-size: 11.5px; color: var(--text-muted); line-height: 1.35; }

.orphan-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: var(--err-bg);
  color: var(--err-fg);
  border: var(--border-w) solid var(--err-border);
  border-left: 3px solid var(--err-solid);
  border-radius: 6px;
  padding: 7px 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

.form-accordion {
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.form-accordion summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
}
.mini-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 10px;
}
.mini-form input, .mini-form textarea, .mini-form select, .input-full, .textarea-full {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-shell);
  font-size: 12px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.word-counter-row { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-secondary); }
.chip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chip-btn {
  background: var(--bg-shell);
  border: 1px solid var(--border);
  padding: 6px 8px;
  font-size: 11.5px;
  text-align: center;
}
.chip-btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }

.rail-right {
  background: var(--bg-shell);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 6px;
}
.rail-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.rail-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.rail-btn.active {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--text-primary);
}

/* Ad slots (disabled by default via ENABLE_ADS=false) */
/* Slots de Publicidade (ocultos por ENABLE_ADS=false; distância >= 40px de qualquer botão) */
.ad-slot {
  margin-top: 40px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
  background: var(--bg-surface);
}
.ad-slot-sidebar {
  margin: 40px 10px 8px;
}
.ad-slot-export {
  margin-top: 40px;
}
.ad-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.ad-box {
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.ad-slot-sidebar .ad-box { width: 100%; aspect-ratio: 300 / 250; min-height: 180px; }
.ad-slot-export .ad-box { width: 100%; max-width: 320px; height: 100px; margin: 0 auto; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 18, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
}
.modal-wide { max-width: 660px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.modal-lead { margin: 0; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.field-label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 500; }
.export-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.export-status { margin: 0; font-size: 12px; color: var(--ok); min-height: 16px; }

.existing-sources { display: flex; flex-direction: column; gap: 6px; }
.source-pick-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  background: var(--bg-shell);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.source-pick-btn:hover { background: var(--bg-hover); border-color: var(--accent); }

.legal-prose h4 { margin: 10px 0 4px; font-size: 13.5px; }
.legal-prose p, .legal-prose li { margin: 0 0 8px; font-size: 12.5px; line-height: 1.55; color: var(--text-secondary); }
.legal-prose ul { padding-left: 18px; margin: 0 0 8px; }
.legal-prose a { color: var(--text-primary); font-weight: 500; }

/* Cookie Consent Banner */
.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 820px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 900;
}
.cookie-banner[hidden] { display: none; }
.cookie-banner p { margin: 0; font-size: 12px; color: var(--text-secondary); flex: 1; min-width: 240px; line-height: 1.45; }
.cookie-actions { display: flex; gap: 8px; }

@media (max-width: 960px) {
  .workspace-shell {
    grid-template-columns: 0px minmax(0, 1fr) 0px 44px;
  }
  .sidebar-left, .sidebar-right { display: none; }
  .mode-selector { grid-template-columns: 1fr; }
}

/* =========================================================
   SELO ZERO IA + MÓDULO 2 (REPARADOR DE CAPA / FOLHA DE ROSTO)
   ========================================================= */
.legal-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.zero-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-shell);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}
.zero-ai-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  border: 1px solid rgba(10, 10, 10, 0.25);
  margin-right: 2px;
  flex-shrink: 0;
}
.zero-ai-strip {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.zero-ai-callout {
  background: var(--bg-shell);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 10px;
}
.zero-ai-callout strong { display: block; font-size: 12.5px; margin-bottom: 4px; }
.zero-ai-callout p { margin: 0; font-size: 12px; }

.panel-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.panel-block-head h3 { margin: 0; }
.btn-xs { padding: 4px 8px; font-size: 11px; border-radius: 6px; }
.check-item-action {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

.modal-split {
  max-width: 980px;
  width: 95vw;
  max-height: 92vh;
}
.modal-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.fm-split-body {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.fm-form-pane {
  padding: 16px 18px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.fm-group {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.fm-group legend {
  padding: 0 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}
.fm-group input, .fm-group textarea, .fm-group select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-shell);
  font-size: 12.5px;
}
.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.toggle-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.toggle-line input { width: auto; }
.fm-postgrad-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

.fm-preview-pane {
  background: var(--bg-canvas);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  overflow-y: auto;
}
.fm-preview-tabs {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 4px;
}
.fm-tab {
  border: none;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}
.fm-tab.active {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
}
.a4-preview-stage {
  width: 100%;
  display: flex;
  justify-content: center;
}
.a4-sheet {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 210 / 297;
  background: #FFFFFF;
  color: #000000;
  border: 1px solid #D4D4D4;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  padding: 10.1% 9.5% 6.7% 14.3%; /* Margens reais proporcionais: 3cm sup, 2cm dir, 2cm inf, 3cm esq */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: Arial, Helvetica, sans-serif;
  text-align: center;
  overflow: hidden;
}
.a4-top { display: flex; flex-direction: column; gap: 6px; }
.a4-inst { font-size: 9.2px; text-transform: uppercase; font-weight: 400; line-height: 1.35; }
.a4-course { font-size: 9.2px; font-weight: 400; line-height: 1.35; }
.a4-authors { font-size: 9.2px; font-weight: 400; line-height: 1.2; margin-top: 4px; white-space: pre-line; }
.a4-authors.bold { font-weight: 700; }
.a4-middle { display: flex; flex-direction: column; gap: 3px; margin: auto 0; }
.a4-title { font-size: 9.5px; text-transform: uppercase; font-weight: 700; line-height: 1.25; }
.a4-subtitle-cover { font-size: 9.2px; font-weight: 700; line-height: 1.25; }
.a4-subtitle-inline { font-size: 9.2px; font-weight: 400; text-transform: none; }
.a4-nature-wrap {
  margin-left: 50%;
  text-align: justify;
  font-size: 7.2px;
  line-height: 1.22;
  color: #000000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.a4-advisor { text-align: left; }
.a4-postgrad { text-align: left; display: flex; flex-direction: column; gap: 2px; }
.a4-bottom { font-size: 9.2px; font-weight: 400; line-height: 1.25; white-space: pre-line; }
.fm-preview-caption {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 820px) {
  .fm-split-body { grid-template-columns: 1fr; overflow-y: auto; }
  .fm-form-pane { border-right: none; border-bottom: 1px solid var(--border); overflow-y: visible; }
}

/* =========================================================
   MÓDULO 3: BUSCADOR LIVRE DE REFERÊNCIAS (APIs ABERTAS)
   ========================================================= */
.ref-subtabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}
.ref-subtab {
  border: none;
  background: transparent;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}
.ref-subtab.active {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
}
.ref-search-form {
  display: flex;
  gap: 6px;
}
.ref-search-form input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
  font-size: 12px;
}
.ref-results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
}
.ref-card {
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ref-card-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
}
.ref-card-meta {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.35;
}
.ref-card-doi {
  font-size: 10.5px;
  color: var(--text-muted);
  word-break: break-all;
}
.ref-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.boolean-box {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.boolean-box h3 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* =========================================================
   MÓDULO 1: REVISÃO DE TEXTO (ORTOGRAFIA + LINTER CIENTÍFICO)
   ========================================================= */
.review-counters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.review-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 11.5px;
  font-weight: 500;
  text-align: center;
}
.lint-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.lint-card {
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: 6px;
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lint-card.spelling { border-left-color: var(--danger); }
.lint-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.lint-tag {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-shell);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
.lint-context {
  font-size: 11.5px;
  color: var(--text-secondary);
  background: var(--bg-shell);
  border-radius: 4px;
  padding: 4px 6px;
  line-height: 1.35;
}
.lint-rec {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}
.lint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}
.custom-dict-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.dict-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  background: var(--bg-shell);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}
.dict-chip button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------- Grupo 2: Trilho ABNT, Sumário Editável e Catálogo de Modelos ---------- */
.abnt-rail-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 12px;
  background: var(--bg-shell);
  border-bottom: 1px solid var(--border);
}
.rail-group { display: inline-flex; align-items: center; gap: 3px; }
.rail-sep { width: 1px; height: 18px; background: var(--border-strong); margin: 0 3px; }
.rail-tool {
  height: 26px;
  min-width: 26px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rail-tool-txt { font-size: 11.5px; padding: 0 8px; }
.rail-tool:hover { background: var(--bg-hover); border-color: var(--border); }
.rail-select {
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-surface);
  font-size: 11.5px;
}

.find-replace-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.find-replace-bar input {
  flex: 1;
  min-width: 110px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg-shell);
  font-size: 12px;
}

.outline-row {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 2px;
}
.outline-row .outline-item { flex: 1; min-width: 0; }
.outline-tools {
  display: inline-flex;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.12s ease;
  flex-shrink: 0;
}
.outline-row:hover .outline-tools,
.outline-row:focus-within .outline-tools { opacity: 1; }
.outline-mini-btn {
  width: 19px;
  height: 19px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.outline-mini-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.outline-mini-btn.danger:hover { background: var(--err-bg); color: var(--err-fg); }

.guide-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--accent-soft);
  color: var(--on-soft);
  border: 1px solid var(--tb-lime-500, #B7CE16);
  border-left: 3px solid var(--tb-lime-600, #8FA10F);
  border-radius: 6px;
  padding: 7px 8px;
  margin-bottom: 6px;
  font-size: 11.5px;
}
.guide-item-btns { display: flex; justify-content: flex-end; gap: 5px; }

.tpl-options-box {
  background: var(--bg-shell);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
}
.tpl-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 8px;
}
.tpl-checks label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font-size: 12px; }
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}
.tpl-card {
  background: var(--bg-shell);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.tpl-card-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.tpl-card p { margin: 0; font-size: 12px; color: var(--text-secondary); line-height: 1.45; flex: 1; }

/* ---------- Módulo 2: Card de Triagem Rápida Pós-Conversão ---------- */
.triage-card {
  background: var(--bg-surface);
  border: var(--border-w) solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex-shrink: 0;
}
.triage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12.5px;
}
.triage-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.triage-text {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-secondary);
}
.triage-undo {
  margin-top: 4px;
  padding: 0;
  font-size: 11px;
}
.triage-pending {
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.triage-note {
  background: var(--info-bg);
  color: var(--info-fg);
  border: 1px solid var(--info-border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.35;
}
.triage-action-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.triage-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.triage-stepper {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.triage-step-item {
  background: var(--bg-shell);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.triage-step-preview {
  font-size: 11px;
  color: var(--text-primary);
  line-height: 1.35;
}
.triage-step-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

/* Módulo 4: Logo da Instituição na Capa e Papel Timbrado */
.a4-logo {
  display: block;
  max-height: 30px;
  max-width: 110px;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0 auto 5px;
}
.form-accordion-nested {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-shell);
  padding: 6px 8px;
  margin-top: 4px;
}
.form-accordion-nested > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.form-accordion-nested > summary::-webkit-details-marker { display: none; }
.form-accordion-nested > summary::after {
  content: "+";
  font-family: var(--font-mono);
  color: var(--text-muted);
}
.form-accordion-nested[open] > summary::after { content: "−"; }
.form-accordion-nested > .mini-form { margin-top: 8px; }
.asset-upload-block {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.asset-upload-block input[type="file"] {
  font-size: 11.5px;
  padding: 4px 0;
}
.asset-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
}
.asset-upload-row .muted-count {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.asset-thumb {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #ffffff;
  flex-shrink: 0;
}

/* Toast de notificação não-bloqueante (ex.: proteção de cursor em pré-textuais) */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: 42px;
  transform: translateX(-50%);
  max-width: min(92vw, 480px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text-1);
  border: var(--border-w) solid var(--line-strong);
  box-shadow: var(--sh-3);
  font-size: 12.5px;
  font-weight: 500;
  z-index: 1200;
}
.app-toast[data-tone="warn"] {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-color: var(--warn-border);
}
.app-toast[data-tone="err"] {
  background: var(--err-bg);
  color: var(--err-fg);
  border-color: var(--err-border);
}

/* Ajustes da Barra de Formatação Desktop (botões >= 36px, texto >= 13px) */
.abnt-rail-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  min-height: 48px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}
.rail-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-shell);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.rail-tool:hover { background: var(--bg-hover); border-color: var(--text-primary); }
.rail-tool-accent {
  background: var(--bg-surface);
  border-color: var(--text-primary);
  font-weight: 600;
}
.rail-select {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
}

/* =========================================================
   PARTE 3: EXPERIÊNCIA MOBILE DO EDITOR (<= 820px)
   Cabeçalho 52px, Gaveta, Chips 40px, Toggle Fluido/A4,
   Bottom Bar 60px + safe-area e Bottom Sheets com alça
   ========================================================= */
@media (max-width: 820px) {
  .editor-topbar {
    height: 52px;
    padding: 0 10px;
    gap: 8px;
  }
  .topbar-brand,
  .topbar-center,
  .topbar-theme-btn,
  .topbar-menu-label,
  .export-label-desktop,
  .abnt-rail-bar,
  .workspace-legal-strip {
    display: none !important;
  }
  .export-label-mobile { display: inline; }
  .topbar-menu-btn {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
  }
  .doc-title-input {
    max-width: none;
    font-size: 14.5px;
    padding: 4px 6px;
  }
  .btn-export-highlight {
    min-height: 40px;
    padding: 0 12px;
    font-size: 13.5px;
  }

  .workspace-body {
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }
  .workspace-center {
    flex: 1;
    min-height: 0;
    width: 100%;
  }

  /* Barra de Ações Rápidas (chips 40px, scroll horizontal suave) */
  .mobile-quick-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-shrink: 0;
  }
  .mobile-quick-bar::-webkit-scrollbar { display: none; }
  .mobile-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1.5px solid var(--border-strong);
    background: var(--bg-shell);
    color: var(--text-primary);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
  }
  .mobile-chip:active { background: var(--bg-hover); }

  /* Toggle [Texto fluido | Prévia A4] no topo da folha */
  .mobile-view-bar {
    display: flex;
    justify-content: center;
    padding: 8px 12px;
    background: var(--bg-canvas);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .mobile-view-toggle {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 3px;
    border-radius: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
  }
  .mv-btn {
    min-height: 36px;
    padding: 0 14px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
  }
  .mv-btn.active {
    background: #DDF247;
    color: #0A0A0A;
    border: 1px solid #0A0A0A;
  }

  .canvas-stage[data-mobile-view="fluid"] {
    width: 100%;
    padding: 0 16px;
    overflow-x: hidden;
  }
  .canvas-stage[data-mobile-view="a4"] {
    width: 100%;
    padding: 0;
    overflow-x: auto;
  }

  /* Overlay escuro translúcido */
  .mobile-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.52);
    z-index: 95;
  }

  /* Gaveta Esquerda Mobile */
  .sidebar-left {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(88vw, 340px);
    z-index: 110;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--sh-3);
    border-right: 2px solid #0A0A0A;
  }
  .sidebar-left.mobile-open {
    display: flex !important;
    transform: translateX(0);
  }
  .sidebar-mobile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    font-size: 15px;
  }
  .sidebar-mobile-shortcuts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
  }
  .drawer-action-btn {
    min-height: 44px;
    padding: 8px 10px;
    border-radius: 9px;
    border: 1px solid var(--border-strong);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
  }

  /* Bottom Sheet do Painel Direito (Raio-X / Referências / Revisão) */
  .sidebar-right {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: min(82vh, 660px);
    z-index: 110;
    border-left: none;
    border-top: 2px solid #0A0A0A;
    border-radius: 18px 18px 0 0;
    box-shadow: var(--sh-3);
    transform: translateY(105%);
    transition: transform 0.22s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .sidebar-right.mobile-open {
    display: flex !important;
    transform: translateY(0);
  }

  /* Bottom Sheet Inserir (grade 2x3+) */
  .mobile-bottom-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 80vh;
    z-index: 115;
    background: var(--bg-surface);
    border-top: 2px solid #0A0A0A;
    border-radius: 18px 18px 0 0;
    box-shadow: var(--sh-3);
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
  }
  .sheet-mobile-handle {
    display: flex;
    justify-content: center;
    padding: 8px 0 2px;
  }
  .sheet-mobile-handle span {
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: var(--border-strong);
  }
  .sheet-mobile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
  }
  .btn-sheet-close {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 9px;
    border: 1.5px solid var(--border-strong);
    background: var(--bg-shell);
    color: var(--text-primary);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
  }
  .mobile-insert-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px 16px;
  }
  .insert-grid-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
    min-height: 68px;
    padding: 12px;
    border-radius: 12px;
    border: 1.5px solid var(--border-strong);
    background: var(--bg-shell);
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
  }
  .insert-grid-btn strong { font-size: 14px; }
  .insert-grid-btn span { font-size: 12px; color: var(--text-muted); }

  /* Barra de Navegação Fixa no Rodapé Mobile (60px + safe-area) */
  .mobile-bottom-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bg-surface);
    border-top: 1.5px solid var(--border-strong);
    z-index: 85;
  }
  .bottom-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 54px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
  }
  .bottom-nav-btn.active {
    color: var(--text-primary);
    background: var(--accent-soft);
  }
  .bottom-nav-icon-wrap {
    position: relative;
    display: inline-flex;
  }
  .mobile-pct-badge {
    position: absolute;
    top: -6px;
    right: -18px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 999px;
    background: #DDF247;
    color: #0A0A0A;
    border: 1px solid #0A0A0A;
  }
}

/* Trava de Exportação / Impressão: papel sempre branco, tinta preta e Arial 12 */
@media print {
  html, body {
    background: #FFFFFF !important;
    color: #000000 !important;
    font-family: Arial, "Liberation Sans", Helvetica, sans-serif !important;
    font-size: 12pt !important;
  }
  .editor-topbar,
  .abnt-rail-bar,
  .mobile-quick-bar,
  .mobile-view-bar,
  .mobile-bottom-bar,
  .mobile-bottom-sheet,
  .mobile-overlay,
  .sidebar-left,
  .sidebar-right,
  .rail-right,
  .topbar,
  .workspace-legal-strip,
  .cookie-banner,
  .modal-backdrop,
  .app-toast {
    display: none !important;
  }
  .workspace-shell,
  .workspace-body,
  .workspace-center,
  .canvas-stage,
  #wordcraft_canvas {
    display: block !important;
    padding: 0 !important;
    background: #FFFFFF !important;
    filter: none !important;
  }
}
