/* Painel do studio: mesma identidade do artigos (Lexend + IBM Plex Mono, escala de cinzas). */
:root {
  --white: #fff;
  --gray-1: #eff2f3;
  --gray-2: #e8ebed;
  --gray-3: #d4d6d8;
  --gray-4: #b0b2b3;
  --gray-5: #757679;
  --gray-6: #606163;
  --gray-7: #282a2d;
  --gray-9: #1b1d20;
  --primary: #aa88ff;
  --ok: #00bf1e;
  --erro: #ff2b0d;
  --rodando: #006bd2;
  --revisao: #ff9900;
  --font-sans: "Lexend", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  accent-color: var(--primary);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--white);
  color: var(--gray-9);
  font: 300 15px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
code, pre, kbd, .mono { font-family: var(--font-mono); -webkit-font-smoothing: auto; }
a { color: inherit; }
h1, h2, h3 { font-weight: 500; line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- topo ---------- */
.topo {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 2rem;
  padding: 0 1.5rem; height: 56px;
  background: var(--white); border-bottom: 1px solid var(--gray-2);
}
.marca { font-weight: 600; text-decoration: none; font-size: 1rem; }
.marca span { font-weight: 300; color: var(--gray-5); }
.site-escolha { display: flex; gap: 0.4rem; align-items: center; font-size: 0.8125rem; }
.site-escolha select { font: 400 0.8125rem/1.2 var(--font-sans); padding: 0.3rem 0.5rem; border: 1px solid var(--gray-3); border-radius: 6px; background: var(--white); color: var(--gray-9); }
.nav { display: flex; gap: 0.25rem; }
.nav a {
  text-decoration: none; padding: 0.35rem 0.75rem; border-radius: 6px; color: var(--gray-6);
}
.nav a:hover { background: var(--gray-1); color: var(--gray-9); }
.nav a.ativo { background: var(--gray-1); color: var(--gray-9); font-weight: 400; }
.conexao { margin-left: auto; font-size: 0.8125rem; color: var(--gray-5); display: flex; align-items: center; gap: 0.4rem; }
.conexao::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--gray-4); }
.conexao.on::before { background: var(--ok); }

.app { max-width: 1280px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* ---------- elementos ---------- */
button, .botao {
  font: 400 0.875rem/1 var(--font-sans);
  padding: 0.6rem 1rem; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--gray-3); background: var(--white); color: var(--gray-9);
}
button:hover:not(:disabled) { border-color: var(--gray-5); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.principal { background: var(--gray-9); border-color: var(--gray-9); color: var(--white); }
button.principal:hover:not(:disabled) { background: var(--gray-7); }
button.perigo:hover:not(:disabled) { border-color: var(--erro); color: var(--erro); }
textarea, select, input[type="text"], input[type="password"] {
  font: 300 0.875rem/1.4 var(--font-sans); color: var(--gray-9);
  border: 1px solid var(--gray-3); border-radius: 6px; padding: 0.5rem 0.65rem; background: var(--white);
}
textarea { width: 100%; resize: vertical; min-height: 4.5rem; }
label { cursor: pointer; }
.mudo { color: var(--gray-5); }
.pequeno { font-size: 0.8125rem; }
.vazio { color: var(--gray-5); padding: 2rem 0; }
.erro-texto { color: var(--erro); }

table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
th { font-weight: 400; color: var(--gray-5); text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--gray-3); white-space: nowrap; }
td { padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--gray-2); vertical-align: top; }
td.c, th.c { text-align: center; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.sim { color: var(--ok); }
.nao { color: var(--gray-4); }
.nao.forte { color: var(--erro); }

/* status */
.status {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.8125rem; white-space: nowrap; color: var(--gray-6);
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gray-4); }
.status.pronto::before, .status.aprovado::before { background: var(--ok); }
.status.aprovado { color: var(--gray-9); }
.status.erro::before, .status.sem-transcript::before { background: var(--erro); }
.status.rodando::before { background: var(--rodando); animation: pulso 1.2s ease-in-out infinite; }
.status.revisao-humana::before { background: var(--revisao); }
.status.descartado { text-decoration: line-through; color: var(--gray-4); }

/* trilha de etapas: o elemento que se repete na lista e no artigo */
.etapas { display: inline-flex; gap: 4px; align-items: center; }
.etapa {
  width: 10px; height: 10px; border-radius: 50%;
  border: 1.5px solid var(--gray-3); background: var(--white);
}
.etapa.ok { background: var(--gray-9); border-color: var(--gray-9); }
.etapa.pulada { background: var(--gray-3); border-color: var(--gray-3); }
.etapa.erro { background: var(--erro); border-color: var(--erro); }
.etapa.rodando { border-color: var(--rodando); background: var(--rodando); animation: pulso 1.2s ease-in-out infinite; }
@keyframes pulso { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .etapa.rodando, .status.rodando::before { animation: none; } }

.trilha { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); margin-top: 1.75rem; }
.trilha li { list-style: none; position: relative; padding-top: 1.1rem; font-size: 0.75rem; color: var(--gray-5); }
.trilha li::before {
  content: ""; position: absolute; top: 4px; left: 0; right: 0; height: 1.5px; background: var(--gray-2);
}
.trilha li .etapa { position: absolute; top: 0; left: 0; }
.trilha li.ok, .trilha li.rodando { color: var(--gray-9); }
.trilha li.ok::before { background: var(--gray-9); }
.trilha li.erro { color: var(--erro); }
.trilha small { display: block; color: var(--gray-5); font-family: var(--font-mono); font-size: 0.6875rem; }
ol.trilha { padding: 0; }

/* ---------- cursos ---------- */
.cursos { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 3rem; }
.lista-cursos { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 88px; align-self: start; }
.lista-cursos h2 { font-size: 0.8125rem; font-weight: 400; color: var(--gray-5); margin-bottom: 0.5rem; }
.lista-cursos a {
  text-decoration: none; padding: 0.55rem 0.75rem; border-radius: 6px; color: var(--gray-6);
  display: flex; justify-content: space-between; gap: 0.5rem;
}
.lista-cursos a:hover { background: var(--gray-1); }
.lista-cursos a.ativo { background: var(--gray-1); color: var(--gray-9); font-weight: 400; }
.lista-cursos a small { color: var(--gray-5); font-size: 0.75rem; }

.cabecalho { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 2rem; }
.cabecalho .meta { margin-top: 0.5rem; color: var(--gray-5); font-size: 0.875rem; }
.acoes { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.secao { margin-top: 2.5rem; }
.secao > h2 { margin-bottom: 1rem; display: flex; align-items: baseline; gap: 0.75rem; }
.secao > h2 small { font-size: 0.8125rem; font-weight: 300; color: var(--gray-5); }

.sugestoes { display: flex; flex-direction: column; border-top: 1px solid var(--gray-2); }
.sugestao { display: grid; grid-template-columns: 1.5rem minmax(0, 1fr) auto; gap: 0.75rem; padding: 0.9rem 0; border-bottom: 1px solid var(--gray-2); }
.sugestao input { margin-top: 0.3rem; width: 16px; height: 16px; }
.sugestao .titulo { font-weight: 400; }
.sugestao .detalhes { color: var(--gray-6); font-size: 0.875rem; margin-top: 0.2rem; }
.sugestao .aulas { font-family: var(--font-mono); font-size: 0.75rem; color: var(--gray-5); margin-top: 0.35rem; }
.sugestao.desligada .titulo { color: var(--gray-5); }
.keyword { font-family: var(--font-mono); font-size: 0.75rem; background: var(--gray-1); padding: 0.1rem 0.4rem; border-radius: 4px; }
.gerar {
  position: sticky; bottom: 0; background: var(--white); padding: 1rem 0; margin-top: 1rem;
  border-top: 1px solid var(--gray-3); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: end;
}
.gerar textarea { min-height: 2.6rem; }
details.check { margin-top: 2.5rem; }
details.check summary { cursor: pointer; font-weight: 500; font-size: 1.125rem; }
details.check summary small { font-weight: 300; font-size: 0.8125rem; color: var(--gray-5); margin-left: 0.5rem; }
details.check table { margin-top: 1rem; }

/* ---------- artigos ---------- */
.linha-artigo { cursor: pointer; }
.linha-artigo:hover td { background: var(--gray-1); }
.linha-artigo .titulo { font-weight: 400; }
.linha-artigo .id { font-family: var(--font-mono); font-size: 0.75rem; color: var(--gray-5); }

.log {
  font: 0.75rem/1.6 var(--font-mono); background: var(--gray-1); border-radius: 8px;
  padding: 0.75rem 1rem; max-height: 420px; overflow: auto; margin: 0;
}
.log div { display: grid; grid-template-columns: 4.5rem 7rem 6rem minmax(0, 1fr); gap: 0.75rem; }
.log .hora, .log .etp { color: var(--gray-5); }
.log .tp { color: var(--gray-6); }
.log .tp.erro, .log div.erro .det { color: var(--erro); }
.log .det { white-space: pre-wrap; word-break: break-word; }
.log.geral div { grid-template-columns: 4.5rem minmax(0, 14rem) 6.5rem 6rem minmax(0, 1fr); }
.log .art { color: var(--gray-6); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- artigo ---------- */
.voltar { font-size: 0.875rem; color: var(--gray-5); text-decoration: none; }
.voltar:hover { color: var(--gray-9); }
.artigo-topo { margin-top: 0.75rem; }
.artigo-topo .id { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--gray-5); margin-top: 0.4rem; }
.resumo { display: flex; gap: 1.5rem; margin-top: 0.75rem; font-size: 0.875rem; color: var(--gray-6); flex-wrap: wrap; align-items: center; }
.alerta { margin-top: 1.25rem; padding: 0.75rem 1rem; border-left: 3px solid var(--erro); background: var(--gray-1); font-size: 0.875rem; white-space: pre-wrap; word-break: break-word; }
.alerta.revisao { border-color: var(--revisao); }

.painel-acoes {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2rem; align-items: start;
  margin-top: 2rem; padding: 1.25rem 0; border-top: 1px solid var(--gray-2); border-bottom: 1px solid var(--gray-2);
}
.painel-acoes .grupo { display: flex; flex-direction: column; gap: 0.5rem; }
.painel-acoes .grupo > span { font-size: 0.8125rem; color: var(--gray-5); }
.painel-acoes .linha { display: flex; gap: 0.5rem; align-items: flex-start; }
.painel-acoes .linha textarea { min-height: 2.4rem; height: 2.4rem; }
.forcar { font-size: 0.8125rem; color: var(--gray-6); display: flex; gap: 0.4rem; align-items: center; }

.abas { display: flex; gap: 0.25rem; margin-top: 2rem; border-bottom: 1px solid var(--gray-3); overflow-x: auto; }
.abas a {
  text-decoration: none; padding: 0.6rem 0.9rem; color: var(--gray-5); font-size: 0.875rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.abas a:hover { color: var(--gray-9); }
.abas a.ativo { color: var(--gray-9); border-color: var(--gray-9); font-weight: 400; }
.abas a.indisponivel { color: var(--gray-4); }
.conteudo-aba { padding-top: 1.75rem; }

.preview { width: 100%; height: 78vh; border: 1px solid var(--gray-3); border-radius: 8px; background: var(--white); }
pre.texto {
  font: 0.8125rem/1.65 var(--font-mono); background: var(--gray-1); border-radius: 8px;
  padding: 1.25rem 1.5rem; white-space: pre-wrap; word-break: break-word; margin: 0; max-width: 90ch;
}
mark { background: #ffe500; color: inherit; padding: 0 1px; border-radius: 2px; }

dl.campos { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 0.6rem 1.5rem; margin: 0; max-width: 960px; }
dl.campos dt { color: var(--gray-5); font-size: 0.875rem; }
dl.campos dd { margin: 0; }
dl.campos ul { margin: 0; padding-left: 1.1rem; }
.contagem { font-family: var(--font-mono); font-size: 0.75rem; color: var(--gray-5); margin-left: 0.5rem; }
.contagem.estourou { color: var(--erro); }

.review { margin-bottom: 2.5rem; max-width: 960px; }
.review h3 { display: flex; gap: 1rem; align-items: baseline; margin-bottom: 0.75rem; }
.nota { font-size: 1.75rem; font-weight: 500; }
.problema { padding: 0.9rem 0; border-top: 1px solid var(--gray-2); display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 1rem; }
.problema .tipo { font-family: var(--font-mono); font-size: 0.75rem; color: var(--gray-6); }
.problema blockquote { margin: 0 0 0.5rem; padding-left: 0.75rem; border-left: 2px solid var(--gray-3); color: var(--gray-6); font-size: 0.875rem; }
.problema .corr { font-size: 0.875rem; margin-top: 0.35rem; }
.problema .corr::before { content: "Correção: "; color: var(--gray-5); }

.passada { margin-bottom: 1.5rem; }
.passada h3 { margin-bottom: 0.5rem; }
.trechos { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.875rem; }
.trechos li { margin-bottom: 0.4rem; }
.trechos q { color: var(--gray-9); }
.trechos span { color: var(--gray-5); }

.url { font-family: var(--font-mono); font-size: 0.75rem; word-break: break-all; }

/* avisos */
.avisos { position: fixed; right: 1.5rem; bottom: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 10; max-width: 420px; }
.aviso { background: var(--gray-9); color: var(--white); padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.875rem; box-shadow: 0 8px 24px rgb(0 0 0 / 0.15); }
.aviso.erro { background: var(--erro); }

@media (max-width: 860px) {
  .cursos { grid-template-columns: 1fr; gap: 1.5rem; }
  .lista-cursos { position: static; }
  .painel-acoes { grid-template-columns: 1fr; }
  .painel-acoes .linha { flex-wrap: wrap; }
  .painel-acoes .linha textarea { flex: 1 1 100%; order: 3; height: auto; min-height: 4.5rem; }
  .trilha { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 1rem; }
  dl.campos { grid-template-columns: 1fr; }
  .topo { gap: 1rem; padding: 0 1rem; }
  .app { padding: 1.5rem 1rem 3rem; }
}

/* ---------- aba Editar (Monaco + preview ao vivo) ---------- */
.app:has(#editor-raiz) { max-width: none; }
.editor-barra { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.75rem; }
.editor-barra kbd { font-size: 0.6875rem; opacity: 0.7; margin-left: 0.3rem; }
.editor-estado { font-size: 0.8125rem; color: var(--gray-5); display: inline-flex; align-items: center; gap: 0.4rem; min-width: 7rem; }
.editor-estado::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.editor-estado.sujo { color: var(--gray-9); font-weight: 400; }
.editor-estado.sujo::before { background: var(--revisao); }
.editor-dica { font-size: 0.8125rem; color: var(--gray-5); margin-left: auto; }
.editor-corpo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; height: calc(100vh - 140px); min-height: 520px; }
.editor-monaco { border: 1px solid var(--gray-3); border-radius: 8px; overflow: hidden; min-height: 0; }
.editor-preview { min-height: 0; display: flex; }
.editor-preview .preview { height: 100%; }
.editor-preview > p { padding: 1rem; }
.editor-msgs { margin-top: 1rem; max-width: 960px; }
.editor-msgs .trechos { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.875rem; }
.editor-msgs .trechos li { margin-bottom: 0.4rem; }
.editor-msgs .trechos span { color: var(--gray-6); }
.juiz-trecho { background: rgba(255, 200, 0, 0.35); border-bottom: 2px solid #ffb000; }
@media (max-width: 900px) {
  .editor-corpo { grid-template-columns: 1fr; height: auto; }
  .editor-monaco, .editor-preview { height: 70vh; }
}

/* ---------- aba Preview editável ---------- */
.app:has(#preview-raiz) { max-width: none; }
.preview-dica { font-size: 0.8125rem; color: var(--gray-5); margin-bottom: 0.5rem; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.preview-dica button { font-size: 0.8125rem; padding: 0.15rem 0.6rem; }
.preview-corpo { display: flex; }
.preview-corpo .preview { height: calc(100vh - 230px); min-height: 520px; }
.preview-corpo > p { padding: 1rem; }
.preview-msgs:not(:empty) { margin-bottom: 0.75rem; max-width: 960px; }
.preview-nota { margin-bottom: 0.5rem; font-size: 0.8125rem; }

/* ---------- login (STUDIO_SENHA) ---------- */
.login { max-width: 22rem; margin: 18vh auto 0; padding: 0 1.5rem; display: grid; gap: 0.75rem; }
.login .marca { margin-bottom: 0.5rem; }
.login input { width: 100%; }
.login .erro-texto { min-height: 1.4em; margin: 0; font-size: 0.8125rem; }
