:root {
  --bg-base: #121214; --bg-surface: #18181b; --bg-subtle: #1f1f23; --bg-hover: #26262b;
  --border: #2a2a30; --border-strong: #3f3f46;
  --text: #e4e4e7; --text-2: #a1a1aa; --text-3: #8a8a93;
  --accent: #d4a54a; --accent-hover: #e0b65e;
  --ok: #6bbf8a; --alerta: #d98c3f; --erro: #e0675a;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg-base); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1 { font-size: 20px; line-height: 1.3; margin: 0; font-weight: 600; }
h2 { font-size: 16px; margin: 0 0 8px; font-weight: 600; }
h3 { font-size: 13px; margin: 16px 0 6px; font-weight: 600; color: var(--text-2); }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* layout */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }
.lateral { background: var(--bg-surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.marca { padding: 16px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.marca .faixa { width: 24px; height: 8px; background: var(--accent); border-radius: 2px; }
.marca b { font-size: 15px; }
.marca small { display: block; color: var(--text-2); font-size: 12px; }
.nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.nav button { all: unset; cursor: pointer; padding: 7px 10px; border-radius: 6px; color: var(--text-2); display: flex; justify-content: space-between; }
.nav button:hover { background: var(--bg-hover); color: var(--text); }
.nav button.ativo { background: var(--bg-subtle); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav kbd, .rodape kbd { font: 11px var(--font); color: var(--text-3); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.rodape { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 12px; }
.rodape .estado { display: flex; align-items: center; gap: 6px; }
.rodape .ponto { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.rodape .ponto.ok { background: var(--ok); }
.principal { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topo { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--border); min-height: 56px; flex-wrap: wrap; }
.topo .sub { color: var(--text-2); font-size: 13px; }
.topo .espaco { flex: 1; }
.conteudo { flex: 1; overflow: auto; min-height: 0; }
.pagina { padding: 24px; max-width: 1200px; }

/* controles */
.btn { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; cursor: pointer; transition: background .12s, border-color .12s; white-space: nowrap; }
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn.primario { background: var(--accent); border-color: var(--accent); color: #18120a; font-weight: 600; }
.btn.primario:hover { background: var(--accent-hover); }
.btn.pequeno { padding: 2px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=search], input[type=date], input[type=number], select, textarea {
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--border-strong); outline: none; }
label.campo { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
.filtros { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.abas { display: flex; gap: 16px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.abas button { all: unset; cursor: pointer; padding: 8px 0; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.abas button.ativo { color: var(--text); border-bottom-color: var(--accent); }

/* badges */
.tag { display: inline-block; font-size: 11px; line-height: 18px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--border); color: var(--text-2); margin: 0 4px 4px 0; white-space: nowrap; }
.tag.ouro { color: var(--accent); border-color: #5a4a26; }
.tag.ok { color: var(--ok); border-color: #2f5a3f; }
.tag.erro { color: var(--erro); border-color: #63322c; }
.tag.alerta { color: var(--alerta); border-color: #5e4128; }
.faixa-Branca { box-shadow: inset 3px 0 0 #e4e4e7; } .faixa-Azul { box-shadow: inset 3px 0 0 #4a7bd4; }
.faixa-Roxa { box-shadow: inset 3px 0 0 #8a5cc4; } .faixa-Marrom { box-shadow: inset 3px 0 0 #8a5a3a; }
.faixa-Preta { box-shadow: inset 3px 0 0 #000; outline: 1px solid #3f3f46; } .faixa-Todas { box-shadow: inset 3px 0 0 var(--text-3); }

/* paineis e listas */
.painel { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.grade2 { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.lista { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg-surface); }
.lista .item { padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.lista .item:last-child { border-bottom: 0; }
.lista .item:hover { background: var(--bg-hover); }
.lista .item.ativo { background: var(--bg-subtle); box-shadow: inset 2px 0 0 var(--accent); }
.lista .item small { color: var(--text-2); display: block; font-size: 12px; }
.grupo-titulo { padding: 6px 12px; font-size: 12px; color: var(--text-3); background: var(--bg-base); border-bottom: 1px solid var(--border); }
.vazio { color: var(--text-2); padding: 24px; text-align: center; }
.vazio .btn { margin-top: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; color: var(--text-2); font-weight: 500; background: var(--bg-surface); position: sticky; top: 0; }
tr:hover td { background: var(--bg-surface); }
dl.ficha { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; }
dl.ficha dt { color: var(--text-2); font-size: 12px; padding-top: 2px; }
dl.ficha dd { margin: 0; }
.mudo { color: var(--text-2); }
.pequeno-txt { font-size: 12px; color: var(--text-2); }

/* arvore */
.arvore-area { display: grid; grid-template-columns: 1fr 380px; height: 100%; min-height: 0; }
.tela-svg { position: relative; overflow: hidden; background: var(--bg-base); cursor: grab; }
.tela-svg.arrastando { cursor: grabbing; }
.tela-svg svg { display: block; width: 100%; height: 100%; }
.zoom { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 4px; }
.legenda { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 12px; font-size: 12px; color: var(--text-2); background: var(--bg-surface); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.detalhe { border-left: 1px solid var(--border); background: var(--bg-surface); overflow: auto; padding: 16px; }
.detalhe h2 { font-size: 16px; }
.no rect { fill: var(--bg-surface); stroke: var(--border); stroke-width: 1; transition: stroke .12s; }
.no:hover rect { stroke: var(--border-strong); }
.no.sel rect { stroke: var(--accent); stroke-width: 2; }
.no text { fill: var(--text); font: 12px var(--font); pointer-events: none; }
.no text.meta { fill: var(--text-2); font-size: 11px; }
.no { cursor: pointer; }
.no.raiz rect { fill: #221d12; stroke: var(--accent); }
.no.acao rect { stroke: #5a4a26; }
.no.reacao rect { stroke: #5e4128; }
.no.reacao.erro rect { stroke: #8a3a32; fill: #1f1615; }
.no.destino rect { fill: var(--bg-subtle); }
.no.destino.fim rect { stroke: #2f5a3f; fill: #141c17; }
.no .marca-tipo { fill: var(--accent); }
.no.reacao .marca-tipo { fill: var(--alerta); }
.no.reacao.erro .marca-tipo { fill: var(--erro); }
.no.destino .marca-tipo { fill: var(--text-3); }
.no.destino.fim .marca-tipo { fill: var(--ok); }
.aresta { fill: none; stroke: var(--border-strong); stroke-width: 1.2; }
.aresta.forte { stroke: #5a4a26; }

/* mapa geral */
.mapa-geral .pos rect { fill: var(--bg-surface); stroke: var(--border-strong); }
.mapa-geral .pos:hover rect { stroke: var(--accent); }
.mapa-geral .pos text { fill: var(--text); font: 13px var(--font); pointer-events: none; }
.mapa-geral .pos text.meta { fill: var(--text-2); font-size: 11px; }
.mapa-geral .pos.fim rect { stroke: #2f5a3f; fill: #141c17; }
.mapa-geral .liga { fill: none; stroke: #3f3f46; }
.mapa-geral .liga.destaque { stroke: var(--accent); }

/* busca */
.sobreposicao { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; z-index: 10; }
.caixa-busca { width: min(640px, 92vw); background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.25); overflow: hidden; }
.caixa-busca input { width: 100%; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 12px 16px; font-size: 15px; background: transparent; }
.caixa-busca .res { max-height: 50vh; overflow: auto; }
.caixa-busca .res .item { padding: 8px 16px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.caixa-busca .res .item.ativo, .caixa-busca .res .item:hover { background: var(--bg-hover); }
.caixa-busca .res .tipo { color: var(--text-3); font-size: 12px; white-space: nowrap; }

/* passos (sequencia/luta) */
.passos { counter-reset: p; display: flex; flex-direction: column; gap: 6px; }
.passos .passo { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: baseline; padding: 6px 10px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 6px; }
.passos .passo::before { counter-increment: p; content: counter(p); color: var(--text-3); font-size: 12px; }
.passos .passo.fim { border-color: #2f5a3f; }
.placar { font-size: 24px; font-weight: 600; color: var(--accent); }

/* graficos */
.barras { display: flex; flex-direction: column; gap: 6px; }
.barra { display: grid; grid-template-columns: 170px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; }
.barra .trilho { height: 10px; background: var(--bg-subtle); border-radius: 3px; overflow: hidden; }
.barra .cheio { height: 100%; background: var(--accent); }
.barra .cheio.ok { background: var(--ok); }
.barra span:last-child { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpis .painel b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.kpis .painel span { color: var(--text-2); font-size: 12px; }

/* markdown */
.md { max-width: 820px; }
.md h1 { margin: 0 0 12px; } .md h2 { margin: 20px 0 8px; font-size: 17px; } .md h3 { color: var(--text); font-size: 14px; }
.md table { margin: 8px 0 16px; border: 1px solid var(--border); }
.md blockquote { margin: 8px 0; padding: 8px 12px; border-left: 2px solid var(--accent); background: var(--bg-surface); color: var(--text-2); }
.md code { background: var(--bg-subtle); padding: 0 4px; border-radius: 4px; }
.video { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 8px; overflow: hidden; margin: 8px 0; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.aviso { padding: 10px 12px; border: 1px solid #5e4128; border-radius: 6px; color: var(--alerta); background: #1c1611; margin-bottom: 12px; }

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .lateral { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .marca, .rodape { display: none; }
  .nav { flex-direction: row; }
  .arvore-area, .grade2 { grid-template-columns: 1fr; }
  .detalhe { border-left: 0; border-top: 1px solid var(--border); max-height: 45vh; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* jornada gamonal */
.jgrade { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.jtrilha { position: relative; }
.jtrilha::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: var(--text); opacity: .85; }
.jfaixa { position: relative; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; padding: 12px 0 20px; }
.jcol { display: flex; flex-direction: column; gap: 12px; z-index: 1; }
.jbelt { display: flex; justify-content: space-between; align-items: stretch; border: 2px solid var(--cor); background: var(--bg-surface); border-radius: 6px; overflow: hidden; }
.jbelt > div { padding: 8px 12px; }
.jbelt b { display: block; font-size: 17px; letter-spacing: .02em; }
.jbelt small { color: var(--text-2); font-size: 11px; letter-spacing: .06em; }
.jbelt .ponta { width: 64px; background: repeating-linear-gradient(90deg, #111 0 6px, #e4e4e7 6px 10px); }
.jbelt .ponta.vermelha { background: #b3261e; }
.jcard { background: var(--bg-surface); border: 1px solid var(--border); border-left: 3px solid var(--cor, var(--border)); border-radius: 8px; padding: 10px 12px; }
.jcard.texto { border-left-color: var(--erro); }
.jcab { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-size: 13px; }
.listras { display: inline-flex; gap: 2px; }
.listras i { width: 4px; height: 12px; background: var(--bg-hover); border-radius: 1px; }
.listras i.on { background: var(--text); }
.jitem { display: flex; gap: 8px; align-items: flex-start; padding: 3px 4px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.jitem:hover { background: var(--bg-hover); }
.jitem.ativo { background: var(--bg-subtle); box-shadow: inset 2px 0 0 var(--accent); }
.jitem input { margin-top: 3px; accent-color: var(--accent); }
.jdetalhe { position: sticky; top: 16px; max-height: calc(100vh - 110px); overflow: auto; }
.jpassos { margin: 0; padding-left: 20px; }
.jpassos li { margin-bottom: 6px; }
.jregras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; border-top: 1px solid var(--border); padding-top: 12px; font-size: 13px; }
@media (max-width: 1200px) { .jgrade { grid-template-columns: 1fr; } .jdetalhe { position: static; max-height: none; } }
@media (max-width: 800px) { .jfaixa { grid-template-columns: 1fr; } .jtrilha::before { display: none; } .jregras { grid-template-columns: 1fr; } }

/* dominância no mapa geral */
.mapa-geral .pos.nivel-1 rect { stroke: #3f3f46; }
.mapa-geral .pos.nivel-2 rect { stroke: #5b5b63; }
.mapa-geral .pos.nivel-3 rect { stroke: #7a6a45; }
.mapa-geral .pos.nivel-4 rect { stroke: #a2853f; }
.mapa-geral .pos.nivel-5 rect { stroke: #c49a45; }
.mapa-geral .pos.nivel-6 rect { stroke: #e0b65e; stroke-width: 2; }

/* aprendizagem: revisão, luta de leitura, jogos, plano de jogo */
.cartao { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-top: 8px; }
.resposta { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.opcoes { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.opcoes .btn { text-align: left; white-space: normal; }
.jform { display: flex; flex-direction: column; gap: 8px; }
.gp-fluxo { padding-left: 20px; } .gp-fluxo li { margin-bottom: 10px; }
.jnivel { font-size: 11px; padding: 1px 4px; width: 118px; flex: none; }
.jnivel.n-aprendi { border-color: #5a4a26; color: var(--accent); }
.jnivel.n-funciona { border-color: #2f5a3f; color: var(--ok); }
@media print { .lateral, .topo, .abas, .jform, .btn { display: none !important; } body { background: #fff; color: #000; } .painel { border: 0; } }

.grade2 > * { min-width: 0; }
select { max-width: 100%; }
.jform select, .campo select { width: 100%; }


/* palavras simples */
.termo { all: unset; cursor: help; color: inherit; border-bottom: 1px dotted var(--accent); }
.termo:hover, .termo:focus-visible { color: var(--accent); }
.caixa-palavra { padding: 16px; max-height: 86vh; overflow: auto; }
.comparacao { color: var(--text-2); border-left: 2px solid var(--accent); padding-left: 10px; font-style: italic; }
.pal-video { margin-top: 10px; }
.palavras-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.palavra-card p { margin: 6px 0; }

/* menu em grupos */
.grupo-nav { padding: 12px 10px 4px; font-size: 11px; color: var(--text-3); letter-spacing: .02em; }
.nav .conta { margin-left: auto; background: var(--accent); color: #121214; border-radius: 8px; font-size: 11px; padding: 0 6px; font-weight: 600; }
.nav .mais-cel { display: none !important; }
.nav .curto { display: none; }

/* hoje */
.hoje { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; max-width: 1100px; }
.hoje .foco { grid-column: 1 / -1; border-color: var(--accent); }
.hoje > * { min-width: 0; }
.destaque { border-left: 3px solid var(--accent); background: var(--bg-subtle); padding: 10px 12px; border-radius: 6px; margin: 10px 0; }
.decs { margin: 4px 0 0; padding-left: 18px; }
.decs li { margin-bottom: 4px; }

/* ficha curta */
.ficha { max-width: 820px; }
.ficha .objetivo, .essencial .objetivo { font-size: 16px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { all: unset; cursor: pointer; padding: 6px 12px; color: var(--text-2); }
.seg button.ativo { background: var(--bg-subtle); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.grade-pos { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.grade-pos .cartao-pos, .grade-tec .painel { display: flex; flex-direction: column; gap: 4px; color: inherit; text-decoration: none; }
.grade-pos .cartao-pos:hover, .grade-tec .painel:hover { border-color: var(--border-strong); text-decoration: none; }
.grade-tec { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
details.mais { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 10px; }
details.mais summary { cursor: pointer; color: var(--accent); }
.essencial { border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 8px; }

/* celular: barra de baixo com 5 atalhos + "Mais" */
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr; height: 100vh; }
  .lateral { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; border-top: 1px solid var(--border); border-bottom: 0; flex-direction: row; overflow: visible; }
  .nav { flex-direction: row; flex-wrap: nowrap; width: 100%; padding: 4px; gap: 0; }
  .nav .grupo-nav, .nav button[data-v]:not(.cel) { display: none; }
  .nav button[data-v].cel, .nav .mais-cel { all: unset; display: flex !important; flex: 1; justify-content: center; padding: 10px 2px; font-size: 12px; text-align: center; cursor: pointer; color: var(--text-2); }
  .nav button.ativo { box-shadow: inset 0 2px 0 var(--accent); }
  .nav.aberto { position: fixed; bottom: 56px; left: 0; right: 0; flex-direction: column; background: var(--bg-surface); border-top: 1px solid var(--border); max-height: 70vh; overflow-y: auto; }
  .nav.aberto .grupo-nav, .nav.aberto button[data-v] { display: flex !important; justify-content: flex-start; padding: 10px 14px; }
  .nav.aberto button[data-v] { font-size: 14px; flex: 0 0 auto; }
  .nav.aberto .mais-cel { flex: 0 0 auto; justify-content: center; border-top: 1px solid var(--border); color: var(--accent); position: sticky; bottom: 0; background: var(--bg-surface); }
  .abas { overflow-x: auto; flex-wrap: nowrap; }
  .abas button { white-space: nowrap; flex: 0 0 auto; }
  .topo { padding: 10px 12px; gap: 8px; }
  .pagina { padding: 12px !important; }
  .hoje { grid-template-columns: 1fr; }
  .btn { min-height: 40px; }
  .ficha .grade2 { grid-template-columns: 1fr; }
  /* celular: letra 16px (abaixo disso o iPhone dá zoom ao tocar no campo) e áreas de toque de 44px */
  body, input, select, textarea { font-size: 16px; }
  .pequeno-txt, .lista .item small, label.campo, th { font-size: 13px; }
  .tag { font-size: 12px; line-height: 22px; }
  .btn, .btn.pequeno, .seg button, .abas button, select { min-height: 44px; }
  .btn.pequeno { padding: 6px 12px; font-size: 14px; }
  .btn { display: inline-flex; align-items: center; }
  .hoje .foco label { flex: 1 1 100%; } .hoje .foco select { width: 100%; }
  .nav .curto { display: inline; } .nav .longo { display: none; }
  .nav.aberto .curto { display: none; } .nav.aberto .longo { display: inline; }
  .nav button[data-v].cel, .nav .mais-cel { min-height: 48px; align-items: center; }
  .lateral { padding-bottom: env(safe-area-inset-bottom); }
  .principal { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}
