/* ==========================================================================
   BASE DE CONHECIMENTO — Layout da aplicacao
   Somente estrutura (grid, espacamento, composicao). Toda cor, raio, sombra e
   tipografia vem dos tokens definidos em meridian.css.
   ========================================================================== */

/* ==========================================================================
   0. TONS DOS TOPICOS
   Cada topico escolhe uma cor da paleta; a classe define as tres variaveis que
   os cards e icones consomem. Nada de cor literal fora daqui.
   ========================================================================== */
.tone-brand   { --tone-bg: var(--brand-50);   --tone-fg: var(--brand-600);   --tone-border: var(--brand-100); }
.tone-info    { --tone-bg: var(--info-50);    --tone-fg: var(--info-600);    --tone-border: var(--info-100); }
.tone-success { --tone-bg: var(--success-50); --tone-fg: var(--success-600); --tone-border: var(--success-100); }
.tone-warning { --tone-bg: var(--warning-50); --tone-fg: var(--warning-600); --tone-border: var(--warning-100); }
.tone-danger  { --tone-bg: var(--danger-50);  --tone-fg: var(--danger-600);  --tone-border: var(--danger-100); }
.tone-neutral { --tone-bg: var(--surface-100);--tone-fg: var(--surface-600); --tone-border: var(--surface-200); }

/* ==========================================================================
   1. SHELL
   ========================================================================== */
body.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* A barra sangra na largura toda; o conteudo dela fica no mesmo eixo do resto. */
.app-header {
  height: 56px;
  background-color: #ffffff;
  border-bottom: 1px solid var(--surface-200);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header .container {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
  padding: 0 20px;
}

/* Reserva a altura antes do cabecalho ser montado, evitando salto de layout. */
#app-header { height: 56px; }

/* Espelha o cabecalho: sangra na largura toda, conteudo no mesmo eixo de
   1140px. `margin-top: auto` prende no rodape da janela quando a pagina e
   curta -- body.app-shell ja e uma coluna flexivel. */
.app-footer {
  margin-top: auto;
  background-color: #ffffff;
  border-top: 1px solid var(--surface-200);
}

.app-footer .container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 20px;
}

.app-footer p { margin: 0; }

/* Na tela de login o rodape nao tem barra: ele flutua sobre o fundo da pagina. */
body.centered-page .app-footer {
  background-color: transparent;
  border-top: 0;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--brand-700);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.app-brand:hover { color: var(--brand-800); }

/* A marca tem proporcao propria (231x255): altura fixa e largura calculada a
   partir dela, para nunca deformar. Dimensoes explicitas evitam o pulo de
   layout enquanto a imagem carrega. */
.app-brand-logo {
  width: 20px;
  height: 22px;
  object-fit: contain;
}

.app-search {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.app-search .meridian-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--surface-400);
  pointer-events: none;
}

.app-search .input { padding-left: 32px; }

.app-header-spacer { flex: 1; }

.app-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 16px;
  border-left: 1px solid var(--surface-200);
}

.app-user-name {
  display: flex;
  flex-direction: column;
  line-height: 16px;
  text-align: right;
}

/* Retrato de uma pessoa. Sem foto, mostra as iniciais sobre o tom da marca.
   Tamanho e corpo das iniciais vem de quem monta o elemento; o corpo e sempre
   um valor da escala tipografica, nunca calculado a partir do diametro. */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: var(--avatar-size, 32px);
  height: var(--avatar-size, 32px);
  border-radius: 50%;
  background-color: var(--brand-100);
  color: var(--brand-700);
  font-weight: 600;
  font-size: var(--avatar-font, 12px);
  line-height: 1;
  text-transform: uppercase;
  overflow: hidden;
  user-select: none;
}

.avatar.has-photo { background-color: var(--surface-100); }

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Foto + nome lado a lado. */
.person {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* ==========================================================================
   2. MENU SUSPENSO
   O design system nao especifica um componente de menu, entao ele e derivado
   dos que existem, em vez de inventado: a superficie segue .table-container
   (borda --surface-200, --radius-md), o cabecalho segue .table th (fundo
   --surface-50, 12px/600, divisor embaixo) e os itens seguem as linhas da
   tabela -- sangrados ate a borda, com hover --surface-50. Sombra --shadow-md,
   um degrau abaixo do modal, que e quem usa --shadow-lg.
   ========================================================================== */
.menu-anchor { position: relative; }

.menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 200;
  min-width: 200px;
  background-color: #ffffff;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.menu-title {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  background-color: var(--surface-50);
  color: var(--surface-600);
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--surface-200);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--surface-800);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.menu-item:hover { background-color: var(--surface-50); }
.menu-item .meridian-icon { color: var(--surface-500); }

/* O contorno de foco padrao tem offset positivo e seria cortado pelo
   `overflow: hidden` da superficie; aqui ele e desenhado para dentro. */
.menu-item:focus-visible { outline: 2px solid var(--brand-500); outline-offset: -2px; }

.menu-item-danger { color: var(--danger-600); }
.menu-item-danger:hover { background-color: var(--danger-50); }
.menu-item-danger .meridian-icon { color: var(--danger-500); }

.menu-separator {
  height: 1px;
  background-color: var(--surface-200);
}

/* ==========================================================================
   3. CONTEUDO
   ========================================================================== */
/* Largura unica de toda a aplicacao. Cabecalho, hero e conteudo compartilham
   o mesmo eixo, entao nada "pula" de largura ao trocar de tela. */
.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 24px 20px 56px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-header-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Acoes no rodape de um painel precisam respirar depois do ultimo campo. */
.panel > .page-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--surface-200);
}

.section-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 14px;
}

/* O espaco entre blocos vive na propria secao, e nao no titulo dentro dela:
   como o titulo e o primeiro filho da <section>, uma margem nele seria
   anulada por `:first-child` e as secoes acabariam coladas. */
.page-section { margin-top: 40px; }

/* ==========================================================================
   4. HERO DA HOME
   ========================================================================== */
.hero {
  padding: 56px 20px 40px;
  text-align: center;
  background-color: #ffffff;
  border-bottom: 1px solid var(--surface-200);
}

.hero .container { padding: 0; }

/* Heading 1 da escala. O hero ganha presenca pelo espaco em volta, nao por um
   tamanho de fonte fora do sistema. */
.hero h1 {
  font-size: 24px;
  line-height: 32px;
  color: var(--surface-900);
  margin-bottom: 8px;
}

.hero p { color: var(--surface-500); margin-bottom: 24px; }

.hero-search {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  background-color: #ffffff;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.hero-search:focus-within {
  border-color: var(--brand-500);
  box-shadow: var(--focus-ring);
}

/* 40px e a altura de .btn-lg: o campo do hero e um controle grande, nao uma
   medida nova. */
.hero-search select,
.hero-search input {
  height: 40px;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--surface-800);
  background-color: transparent;
  box-shadow: none;
  border-radius: 0;
}

.hero-search select {
  flex-shrink: 0;
  max-width: 190px;
  padding: 0 28px 0 14px;
  color: var(--surface-600);
  border-right: 1px solid var(--surface-200);
  background-color: var(--surface-50);
}

.hero-search input { flex: 1; min-width: 0; padding: 0 14px; }

.hero-search button {
  flex-shrink: 0;
  width: 52px;
  height: 40px;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.hero-suggestions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.hero-suggestions .label { color: var(--surface-500); }

/* ==========================================================================
   5. CARDS DE TOPICO
   ========================================================================== */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.topic-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  background-color: #ffffff;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.topic-card:hover {
  border-color: var(--brand-300);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.topic-card-media {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background-color: var(--tone-bg);
  color: var(--tone-fg);
  border: 1px solid var(--tone-border);
  overflow: hidden;
}

/* Capa enviada: entra inteira (`contain`), nunca cortada, sobre fundo neutro
   para nao tingir a marca com a cor do topico. Vale para o card, o bloco de
   subtopico e a arvore do painel. */
.topic-card-media.has-cover,
.tile-icon.has-cover,
.tree-icon.has-cover {
  background-color: #ffffff;
  border-color: var(--surface-200);
}

.topic-card-media img,
.tile-icon img,
.tree-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.topic-card h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--surface-900);
}

.topic-card h3 .meridian-icon { color: var(--surface-400); }
.topic-card:hover h3 { color: var(--brand-700); }

.topic-card p {
  color: var(--surface-500);
  font-size: 14px;
  line-height: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.topic-card-count {
  margin-top: auto;
  padding-top: 6px;
  color: var(--surface-400);
}

/* --- Grade de blocos com icone (subtopicos) --- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1px;
  background-color: var(--surface-200);
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background-color: #ffffff;
  color: inherit;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.tile:hover { background-color: var(--surface-50); }

.tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background-color: var(--tone-bg);
  color: var(--tone-fg);
  border: 1px solid var(--tone-border);
  overflow: hidden;
}

.tile-text { display: flex; flex-direction: column; min-width: 0; }
.tile-text strong { color: var(--surface-800); font-weight: 600; }
.tile:hover .tile-text strong { color: var(--brand-700); }

/* ==========================================================================
   6. LISTA DE ARTIGOS
   ========================================================================== */
.article-list {
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  overflow: hidden;
}

.article-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--surface-100);
  transition: background-color 0.15s ease;
}

.article-row:last-child { border-bottom: none; }
.article-row:hover { background-color: var(--surface-50); }
.article-row > .meridian-icon { color: var(--surface-400); flex-shrink: 0; }

.article-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.article-row-title {
  color: var(--brand-700);
  font-weight: 500;
}

.article-row:hover .article-row-title { text-decoration: underline; }

.article-row-summary {
  color: var(--surface-500);
  font-size: 12px;
  line-height: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  color: var(--surface-400);
}

.tag-list { display: flex; gap: 4px; flex-wrap: wrap; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  background-color: var(--brand-50);
  color: var(--brand-700);
  border: 1px solid var(--brand-100);
}

/* ==========================================================================
   7. TRILHA
   ========================================================================== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  color: var(--surface-500);
}

.breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--surface-600);
  text-decoration: none;
}

.breadcrumb a:hover { color: var(--brand-700); text-decoration: underline; }
.breadcrumb .meridian-icon { color: var(--surface-300); }

/* ==========================================================================
   8. ESTADOS AUXILIARES
   ========================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 20px;
  background-color: #ffffff;
  border: 1px dashed var(--surface-300);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--surface-500);
}

.empty-state .meridian-icon { color: var(--surface-400); }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-danger { background-color: var(--danger-50); border-color: var(--danger-100); color: var(--danger-600); }
.alert-success { background-color: var(--success-50); border-color: var(--success-100); color: var(--success-600); }
.alert-warning { background-color: var(--warning-50); border-color: var(--warning-100); color: var(--warning-600); }
.alert-info { background-color: var(--info-50); border-color: var(--info-100); color: var(--info-600); }
.alert .meridian-icon { flex-shrink: 0; margin-top: 1px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background-color: var(--surface-900);
  color: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.active { opacity: 1; transform: translateY(0); }
.toast-danger { background-color: var(--danger-600); }

.loading-line {
  height: 3px;
  background-color: var(--brand-100);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  margin-bottom: 16px;
}

.loading-line::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background-color: var(--brand-500);
  animation: loading-slide 1.1s ease-in-out infinite;
}

@keyframes loading-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

/* Botao ocupado ------------------------------------------------------------
   O rotulo some por `color: transparent` -- e nao por `visibility` nos filhos
   -- porque muitos botoes tem o texto solto, sem elemento em volta, e texto
   solto nao e alcancavel por seletor. Como os icones desenham com
   `currentColor`, some tudo de uma vez.

   A largura do botao nao muda: o conteudo continua ocupando o mesmo espaco,
   so invisivel. Sem isso, a barra de acoes daria um salto a cada clique. */
.btn.is-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

/* Centragem por margem negativa, e nao por `translate(-50%, -50%)`: a animacao
   ja usa `transform` para girar, e o segundo transform apagaria o primeiro. */
.btn.is-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid var(--btn-spinner, currentColor);
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}

/* Botao pequeno, giro pequeno -- 14px transbordaria de um botao de 28px. */
.btn-sm.is-loading::after,
.btn-icon.btn-sm.is-loading::after {
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-width: 2px;
}

/* O giro precisa de cor propria: `currentColor` foi zerado acima. */
.btn-primary { --btn-spinner: #ffffff; }
.btn-danger { --btn-spinner: #ffffff; }
.btn-secondary { --btn-spinner: var(--surface-700); }
.btn-outline { --btn-spinner: var(--brand-700); }
.btn-ghost { --btn-spinner: var(--surface-700); }

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* Quem pediu para reduzir movimento ve o estado, nao a animacao. */
@media (prefers-reduced-motion: reduce) {
  .btn.is-loading::after { animation: none; }
  .loading-line::after { animation: none; }
}

/* ==========================================================================
   9. PAGINA CENTRALIZADA (login e erro)
   ========================================================================== */
/* Coluna, e nao linha: com o rodape presente, `justify-content: center`
   colocaria cartao e rodape lado a lado. O `margin: auto` do cartao centraliza
   no espaco que sobra e empurra o rodape para baixo. */
body.centered-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

body.centered-page .auth-card { margin: auto; }

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 28px;
  background-color: #ffffff;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.auth-card form { text-align: left; }

/* Sem a caixa colorida que existia aqui: a marca ja carrega a cor da empresa,
   e o traco preto dela nao se sustenta sobre o azul. */
.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
}

.auth-logo img {
  width: 40px;
  height: 44px;
  object-fit: contain;
}

.auth-subtitle { margin: 4px 0 22px; }

.error-code {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--brand-600);
  margin-bottom: 4px;
}

.auth-card .btn { margin-top: 4px; }

/* ==========================================================================
   10. LEITURA DE ARTIGO
   ========================================================================== */
/* Artigo + sumário lateral, dentro do mesmo eixo de 1140px. */
.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 236px;
  gap: 20px;
  align-items: start;
}

.article-page {
  background-color: #ffffff;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-lg);
  padding: 32px 36px 40px;
  min-width: 0;
}

/* --- Sumário --- */
.article-toc {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 96px);
  background-color: #ffffff;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* Mesma faixa de cabeçalho de .table th. */
.article-toc-title {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  background-color: var(--surface-50);
  color: var(--surface-600);
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--surface-200);
}

.article-toc nav { overflow-y: auto; padding: 4px 0; }

.article-toc a {
  display: block;
  padding: 6px 12px 6px 14px;
  border-left: 2px solid transparent;
  color: var(--surface-600);
  font-size: 14px;
  line-height: 16px;
  text-decoration: none;
}

.article-toc a:hover { background-color: var(--surface-50); color: var(--surface-800); }

.article-toc a.level-3 {
  padding-left: 26px;
  font-size: 12px;
  color: var(--surface-500);
}

.article-toc a.is-active {
  border-left-color: var(--brand-600);
  background-color: var(--brand-50);
  color: var(--brand-700);
  font-weight: 500;
}

/* Compensa o cabeçalho fixo ao pular para uma seção. */
.article-body h2,
.article-body h3 { scroll-margin-top: 76px; }

.article-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--surface-200);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.article-head-text { flex: 1; min-width: 0; }
.article-head h1 { margin-bottom: 8px; }

/* Acoes discretas: um unico botao-icone alinhado ao titulo. A aparencia vem
   de .btn-ghost, a mesma da engrenagem do cabecalho. */
.article-actions { flex-shrink: 0; }

.article-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--surface-500);
  margin-bottom: 10px;
}

.article-meta .separator { color: var(--surface-300); }

/* --- Corpo renderizado --- */
.article-body { color: var(--surface-800); }
.article-body > * + * { margin-top: 16px; }

.article-body h2 {
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  margin-top: 32px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--surface-200);
}

.article-body h3 { font-size: 16px; line-height: 24px; font-weight: 600; margin-top: 24px; }
.article-body h4 { font-size: 14px; line-height: 20px; font-weight: 600; margin-top: 20px; }

.article-body p { line-height: 20px; }

.article-body a { color: var(--brand-700); text-decoration: underline; }
.article-body a:hover { color: var(--brand-800); }

.article-body ul, .article-body ol { padding-left: 22px; }
.article-body li { line-height: 20px; }
.article-body li + li { margin-top: 4px; }

.article-body blockquote {
  padding: 8px 16px;
  border-left: 3px solid var(--brand-300);
  background-color: var(--brand-50);
  color: var(--surface-700);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 5px;
  background-color: var(--surface-100);
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-sm);
}

.article-body pre {
  padding: 14px 16px;
  background-color: var(--surface-50);
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.article-body pre code {
  padding: 0;
  background: none;
  border: none;
  font-size: 12px;
  line-height: 16px;
}

.article-body img, .article-body video {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
}

.article-body figure { text-align: center; }
.article-body figure > * + * { margin-top: 8px; }

.article-body figcaption {
  font-size: 12px;
  line-height: 16px;
  color: var(--surface-500);
}

.article-body hr { border: none; border-top: 1px solid var(--surface-200); }

.article-body table {
  display: block;
  overflow-x: auto;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
}

.article-body table td { white-space: normal; }

/* Video embutido: proporcao 16:9 sem depender de JavaScript. */
.video-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-200);
  background-color: var(--surface-900);
  overflow: hidden;
}

.video-embed iframe,
.video-embed video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
}

/* --- Anexos --- */
.attachments { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--surface-200); }
.attachments h2 { margin-bottom: 12px; }

.attachment-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 8px;
  list-style: none;
}

.attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  background-color: var(--surface-50);
  color: var(--surface-800);
  text-decoration: none;
}

.attachment:hover { border-color: var(--brand-300); background-color: var(--brand-50); }
.attachment .meridian-icon { color: var(--brand-600); flex-shrink: 0; }

.attachment-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.attachment-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   11. BUSCA
   ========================================================================== */
.search-result {
  display: block;
  padding: 16px;
  background-color: #ffffff;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  color: inherit;
  text-decoration: none;
}

.search-result + .search-result { margin-top: 8px; }
.search-result:hover { border-color: var(--brand-300); box-shadow: var(--shadow-xs); }

.search-result-trail {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  color: var(--surface-400);
  margin-bottom: 4px;
}

.search-result h3 { color: var(--brand-700); margin-bottom: 6px; }
.search-result:hover h3 { text-decoration: underline; }

.search-snippet { color: var(--surface-600); font-size: 14px; line-height: 20px; }
.search-snippet mark {
  background-color: var(--warning-50);
  color: var(--surface-900);
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 0 2px;
}

/* ==========================================================================
   12. PAINEIS E FORMULARIOS
   ========================================================================== */
.panel {
  background-color: #ffffff;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  padding: 20px;
}

.panel + .panel { margin-top: 16px; }

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--surface-200);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* --------------------------------------------------------------------------
   Acesso por topico (painel do administrador)
   -------------------------------------------------------------------------- */
.modal-wide { max-width: 620px; }

.access-modes { display: flex; flex-direction: column; gap: 6px; }

.access-mode {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.access-mode:hover { border-color: var(--brand-400); background-color: var(--brand-50); }
.access-mode:has(input:checked) { border-color: var(--brand-600); background-color: var(--brand-50); }
.access-mode input { margin-top: 3px; accent-color: var(--brand-600); }
.access-mode > span { display: flex; flex-direction: column; gap: 2px; }

.access-tree {
  max-height: 300px;
  overflow-y: auto;
  margin-top: 6px;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  background-color: #ffffff;
}

.access-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border-bottom: 1px solid var(--surface-100);
  cursor: pointer;
}

.access-item:last-child { border-bottom: none; }
.access-item:hover { background-color: var(--surface-50); }
.access-item input { accent-color: var(--brand-600); }
.access-item .meridian-icon { color: var(--surface-500); }
.access-item-title { flex: 1; min-width: 0; }
.access-item:has(input:disabled) { color: var(--surface-500); }

.access-item.level-1 { padding-left: 32px; }
.access-item.level-2 { padding-left: 52px; }
.access-item.level-3 { padding-left: 72px; }

/* Bloco da foto de perfil, no topo dos dados da conta. */
.avatar-editor {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--surface-200);
}

.avatar-editor-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.avatar-editor-actions .page-actions { margin-top: 8px; }

/* Enquadramento da foto ----------------------------------------------------
   O quadrado da tela E o recorte: o que aparece aqui e exatamente o que vai
   para o arquivo. O circulo por cima e so a lembranca de como a foto sera
   exibida -- a imagem gravada continua quadrada, porque o avatar aparece
   redondo em uns lugares e quadrado em outros. */
.crop-stage {
  position: relative;
  width: 280px;
  height: 280px;
  max-width: 100%;
  margin: 0 auto 16px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background-color: var(--surface-100);
}

.crop-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;  /* o arraste e nosso, nao da rolagem da pagina */
}

.crop-stage canvas.is-dragging { cursor: grabbing; }
.crop-stage canvas:focus-visible { outline: none; }

/* A moldura nao intercepta o ponteiro: o arraste pertence ao canvas embaixo.
   O escurecimento fora do circulo e um gradiente de parada dura -- com
   `closest-side` o raio acompanha o tamanho do palco, entao a moldura continua
   certa quando a tela encolhe. A cor e a mesma que o design system usa nos
   overlays de modal. */
.crop-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(
    circle closest-side at 50% 50%,
    transparent 0 99%,
    rgba(16, 24, 40, 0.5) 100%
  );
}

.crop-stage canvas:focus-visible + .crop-frame {
  outline: var(--focus-ring);
  outline-offset: -2px;
}

.crop-help { text-align: center; }

/* Controle de aproximacao --------------------------------------------------
   O range nativo nao herda nada do design system, entao a trilha e o pino sao
   desenhados aqui com os mesmos tokens dos demais controles. */
.range {
  width: 100%;
  height: 20px;
  padding: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--radius-sm);
  background-color: var(--surface-200);
}

.range::-moz-range-track {
  height: 4px;
  border-radius: var(--radius-sm);
  background-color: var(--surface-200);
}

.range::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;  /* centraliza o pino de 16px na trilha de 4px */
  border: 1px solid var(--brand-600);
  border-radius: 50%;
  background-color: var(--brand-600);
  box-shadow: var(--shadow-xs);
}

.range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 1px solid var(--brand-600);
  border-radius: 50%;
  background-color: var(--brand-600);
  box-shadow: var(--shadow-xs);
}

.range:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

.settings-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  background-color: #ffffff;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  position: sticky;
  top: 72px;
}

.settings-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--surface-600);
  text-decoration: none;
  font-weight: 500;
}

.settings-nav a:hover { background-color: var(--surface-100); color: var(--surface-800); }
.settings-nav a[aria-current="page"] { background-color: var(--brand-50); color: var(--brand-700); }
.settings-nav .meridian-icon { color: var(--surface-400); }
.settings-nav a[aria-current="page"] .meridian-icon { color: var(--brand-600); }

/* --- Seletor de icone e cor --- */
.icon-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
  max-height: 176px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-md);
  background-color: var(--surface-50);
}

.icon-option {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background-color: #ffffff;
  color: var(--surface-600);
  cursor: pointer;
}

.icon-option:hover { border-color: var(--brand-300); color: var(--brand-700); }

.icon-option[aria-pressed="true"] {
  background-color: var(--brand-600);
  border-color: var(--brand-600);
  color: #ffffff;
}

.color-picker { display: flex; gap: 8px; flex-wrap: wrap; }

.color-option {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--tone-border);
  background-color: var(--tone-bg);
  color: var(--tone-fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.color-option[aria-pressed="true"] {
  border-color: var(--tone-fg);
  box-shadow: 0 0 0 2px var(--tone-bg);
}

.color-option .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: currentColor;
}

/* ==========================================================================
   13. CONSTRUTOR DA ARVORE
   ========================================================================== */
.tree { list-style: none; }
.tree ul { list-style: none; margin-left: 26px; border-left: 1px dashed var(--surface-300); padding-left: 10px; }

.tree-node {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 4px;
  background-color: #ffffff;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
}

.tree-node:hover { border-color: var(--brand-300); }
.tree-node.dragging { opacity: 0.45; }
.tree-node.drop-target { border-color: var(--brand-500); background-color: var(--brand-50); }

.tree-handle {
  display: flex;
  align-items: center;
  color: var(--surface-300);
  cursor: grab;
}

.tree-handle:active { cursor: grabbing; }

.tree-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background-color: var(--tone-bg);
  color: var(--tone-fg);
  border: 1px solid var(--tone-border);
  overflow: hidden;
}

.tree-label { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tree-label strong { font-weight: 500; }
.tree-actions { display: flex; gap: 4px; flex-shrink: 0; }
.tree-actions .btn { box-shadow: none; }

.tree-empty {
  padding: 8px 10px;
  margin-bottom: 4px;
  color: var(--surface-400);
  font-size: 12px;
  border: 1px dashed var(--surface-200);
  border-radius: var(--radius-md);
}

.tree-empty.drop-target { border-color: var(--brand-500); background-color: var(--brand-50); }

/* ==========================================================================
   14. EDITOR VISUAL
   ========================================================================== */
.editor-shell {
  background-color: #ffffff;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  /* Sem `overflow: hidden` aqui de proposito. Ele tornaria este elemento o
     contexto de rolagem da barra sticky abaixo e, como ele nao rola, o
     `top` empurraria a barra para dentro do texto, cobrindo as primeiras
     linhas do artigo. As bordas arredondadas vem dos filhos. */
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  padding: 8px;
  background-color: var(--surface-50);
  border-bottom: 1px solid var(--surface-200);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  position: sticky;
  top: 56px;
  z-index: 50;
}

.editor-toolbar .btn { box-shadow: none; background: none; border-color: transparent; }
.editor-toolbar .btn:hover { background-color: var(--surface-200); }
.editor-toolbar .btn.is-active { background-color: var(--brand-100); color: var(--brand-700); }
.editor-toolbar select.input { width: auto; height: 32px; font-size: 14px; box-shadow: none; }
.editor-toolbar .divider { width: 1px; height: 20px; background-color: var(--surface-300); margin: 0 5px; }
.editor-toolbar .spacer { flex: 1; }

.editor-surface {
  min-height: 60vh;
  padding: 28px 32px 40px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  outline: none;
}

.editor-surface:focus { outline: none; }

.editor-surface:empty::before {
  content: attr(data-placeholder);
  color: var(--surface-400);
}

/* Só quando não há bloco onde ancorar a linha (editor vazio). */
.editor-surface.drag-over {
  background-color: var(--brand-50);
  box-shadow: inset 0 0 0 2px var(--brand-300);
}

/* Arrastar para uma posição -----------------------------------------------
   Âncora da linha de destino. Sem isto ela se posicionaria em relação à
   página e ficaria parada enquanto o editor rola. */
#editor-host { position: relative; }

/* A linha marca a fronteira entre dois blocos — é ali que o arquivo entra.
   O ponto na ponta esquerda dá o mesmo sinal do cursor de texto: "começa
   aqui". Não intercepta o ponteiro, senão engoliria o próprio `drop`. */
.drop-line {
  position: absolute;
  height: 2px;
  background-color: var(--brand-600);
  border-radius: var(--radius-sm);
  pointer-events: none;
  z-index: 60;
}

.drop-line::before {
  content: "";
  position: absolute;
  top: -3px;
  left: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--brand-600);
}

/* Remover mídia do texto -------------------------------------------------
   Aparece sobre a imagem, o vídeo ou o anexo que está sob o ponteiro. Fica
   fora da área editável: dentro dela viraria conteúdo do artigo. */
.media-remove {
  position: absolute;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  color: var(--surface-600);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.media-remove:hover {
  border-color: var(--danger-600);
  background-color: var(--danger-600);
  color: #ffffff;
}

.media-remove:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

/* Card do video dentro do editor: o player real so aparece na leitura. */
.editor-surface .video-embed {
  padding-top: 0;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background-color: var(--surface-100);
  border: 1px dashed var(--surface-300);
  color: var(--surface-600);
  cursor: default;
}

.editor-surface .video-embed::after {
  content: "Vídeo — aparece no artigo publicado";
  font-size: 12px;
}

.editor-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 20px;
  background-color: #ffffff;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.editor-footer .status-text { margin-right: auto; color: var(--surface-500); }

/* Troca do motor de edicao, na propria tela onde ele e usado. */
.engine-select {
  width: auto;
  height: 32px;
  font-size: 12px;
  color: var(--surface-600);
}

/* O motor opcional Quill nao tem CSS nosso, de proposito. Ele roda com o
   tema `snow` dele e mais nada: cada regra que mirava `.ql-*` daqui virou
   defeito depois -- a ultima foi a largura fixa do seletor de titulo. Se
   algo nele parecer fora do lugar, o lugar de ajustar e o proprio Quill. */

/* --- Zona de envio e lista de anexos --- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px;
  border: 1px dashed var(--surface-300);
  border-radius: var(--radius-md);
  background-color: var(--surface-50);
  color: var(--surface-500);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone:hover, .dropzone.dragging {
  border-color: var(--brand-400);
  background-color: var(--brand-50);
  color: var(--brand-700);
}

/* "ou" entre dois caminhos igualmente válidos — no diálogo de vídeo, enviar do
   computador e colar um link. A linha atravessa e o rótulo abre espaço nela. */
.or-separator {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--surface-500);
  font-size: 12px;
}

.or-separator::before,
.or-separator::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: var(--surface-200);
}

/* Campo com o botão de confirmar colado nele: o link do vídeo é curto e a
   ação é imediata, então mandar o usuário até o rodapé do modal seria desvio. */
.field-with-action {
  display: flex;
  gap: 8px;
  align-items: center;
}

.field-with-action .input { flex: 1; min-width: 0; }

.asset-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  margin-top: 12px;
}

.asset-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  color: var(--surface-600);
}

.asset-option:hover { border-color: var(--brand-400); background-color: var(--brand-50); }
.asset-option img { width: 100%; height: 62px; object-fit: cover; border-radius: var(--radius-sm); }
.asset-option .placeholder {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 62px; border-radius: var(--radius-sm);
  background-color: var(--surface-100); color: var(--surface-500);
}
.asset-option span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Prévia da tabela, no diálogo de inserção --- */
.table-preview {
  margin: 8px 0 6px;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-preview .table { table-layout: fixed; }
.table-preview th { font-size: 12px; height: 32px; }

.table-preview td {
  height: 32px;
  border-right: 1px solid var(--surface-100);
  cursor: pointer;
}

.table-preview td:last-child { border-right: none; }
.table-preview td:hover { background-color: var(--brand-50); }
.table-preview tr:hover { background-color: transparent; }

/* --- Progresso do envio --- */
.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--brand-200);
  border-radius: var(--radius-md);
  background-color: var(--brand-50);
  color: var(--brand-800);
}

.upload-item .meridian-icon { color: var(--brand-600); flex-shrink: 0; }
.upload-item .upload-name { min-width: 0; flex-shrink: 0; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.upload-bar {
  flex: 1;
  height: 6px;
  min-width: 80px;
  border-radius: var(--radius-sm);
  background-color: var(--brand-100);
  overflow: hidden;
}

.upload-bar-fill {
  display: block;
  height: 100%;
  width: var(--upload-progress, 0%);
  background-color: var(--brand-600);
  border-radius: var(--radius-sm);
  transition: width 0.15s linear;
}

/* Servidor sem Content-Length: mostra atividade em vez de uma barra parada. */
.upload-bar-fill.indeterminate {
  width: 40%;
  animation: loading-slide 1.1s ease-in-out infinite;
}

.upload-percent { flex-shrink: 0; min-width: 46px; text-align: right; color: var(--brand-700); }

.asset-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--surface-200);
  border-radius: var(--radius-md);
  background-color: #ffffff;
}

.asset-row + .asset-row { margin-top: 6px; }
.asset-row .meridian-icon { color: var(--surface-500); }

/* A linha inteira é arrastável até o ponto do texto. O cursor é o único aviso
   disponível: não há espaço aqui para uma instrução escrita por anexo. */
.asset-row[draggable="true"] { cursor: grab; }
.asset-row[draggable="true"]:active { cursor: grabbing; }
.asset-row[draggable="true"]:hover { border-color: var(--brand-300); }

/* Os botões dentro da linha continuam clicáveis, não arrastáveis. */
.asset-row .asset-actions .btn { cursor: pointer; }
.asset-row .asset-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-actions { display: flex; gap: 4px; }

.asset-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-200);
}

/* --- Campo de tags com chips --- */
.tag-input {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 36px;
  padding: 4px 8px;
  background-color: #ffffff;
  border: 1px solid var(--surface-300);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

.tag-input:focus-within {
  border-color: var(--brand-500);
  box-shadow: var(--focus-ring);
}

.tag-input input {
  flex: 1;
  min-width: 100px;
  height: 26px;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--surface-800);
  background: transparent;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 8px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background-color: var(--brand-50);
  color: var(--brand-700);
  border: 1px solid var(--brand-100);
}

.tag-chip button {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: none;
  background: none;
  color: var(--brand-600);
  cursor: pointer;
}

.tag-chip button:hover { color: var(--danger-600); }

/* --- Chips de filtro --- */
.filter-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }

.filter-chip {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  color: var(--surface-600);
  background-color: #ffffff;
  border: 1px solid var(--surface-300);
  /* Mesmo raio dos botoes: a escala do sistema vai ate 8px, nao tem pilula. */
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.filter-chip:hover { background-color: var(--surface-100); }

.filter-chip[aria-pressed="true"] {
  background-color: var(--brand-600);
  border-color: var(--brand-600);
  color: #ffffff;
}

/* ==========================================================================
   15. TABELA (ajustes de linha)
   ========================================================================== */
.table td.cell-wrap { white-space: normal; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ==========================================================================
   16. RESPONSIVO
   ========================================================================== */
@media (max-width: 980px) {
  /* O sumário deixa de ser coluna e vira um bloco antes do texto. */
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .article-toc { position: static; order: -1; max-height: 240px; }
}

@media (max-width: 900px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; }
}

@media (max-width: 720px) {
  .app-header { gap: 8px; padding: 0 12px; }
  .app-search { display: none; }
  .app-user-name { display: none; }
  .app-main { padding: 16px 12px 32px; }
  .hero { padding: 36px 16px 28px; }
  .hero h1 { font-size: 24px; line-height: 32px; }
  .hero-search select { display: none; }
  .article-page { padding: 20px 16px 28px; }
  .editor-surface { padding: 20px 16px 32px; }
  .field-row { grid-template-columns: 1fr; }
  .editor-toolbar { top: 56px; }
}
