/* Central de Estudos — tema escuro/claro, celular primeiro */
:root, [data-tema="escuro"] {
  --fundo: #101317; --painel: #181c22; --painel2: #1f242c; --borda: #2b313b;
  --texto: #e9ecf1; --sutil: #9aa3b2; --acento: #f2b705; --acento-txt: #15181c;
  --ok: #3fb950; --erro: #f2545b; --info: #4ea1ff; --ined: #b392f0;
}
[data-tema="claro"] {
  --fundo: #f4f5f7; --painel: #ffffff; --painel2: #eef0f3; --borda: #d9dde3;
  --texto: #1b1f24; --sutil: #5d6673; --acento: #c99400; --acento-txt: #ffffff;
  --ok: #1f883d; --erro: #cf222e; --info: #0969da; --ined: #8250df;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fundo); color: var(--texto); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--info); }
h1 { font-size: 1.5rem; margin: .2em 0 .6em; }
h2 { font-size: 1.12rem; margin: 0 0 .6em; }
h3 { font-size: 1rem; margin: 0 0 .4em; }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: .88em; }
pre { background: var(--painel2); padding: 12px; border-radius: 8px; overflow: auto; }
.sr { position: absolute; left: -9999px; }
.sr:focus { left: 8px; top: 8px; background: var(--acento); color: var(--acento-txt); padding: 6px 10px; z-index: 50; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }

/* layout */
.app { display: flex; min-height: 100vh; }
.lateral { width: 230px; flex: none; background: var(--painel); border-right: 1px solid var(--borda); padding: 18px 12px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; }
.marca b { display: block; font-size: 1.05rem; }
.marca small { color: var(--acento); font-size: .8rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--texto); text-decoration: none; padding: 8px 10px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
.nav a:hover { background: var(--painel2); }
.nav a[aria-current="page"] { background: var(--painel2); box-shadow: inset 3px 0 0 var(--acento); }
.nav .sair { margin-top: 8px; }
.lateral-pe { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.salvo { font-size: .75rem; color: var(--sutil); }
.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topo { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 22px; border-bottom: 1px solid var(--borda); background: var(--painel); font-size: .9rem; }
.cronometro { font-variant-numeric: tabular-nums; color: var(--acento); font-weight: 600; }
.conteudo { padding: 22px; max-width: 1050px; width: 100%; outline: none; }
.faixa { background: var(--acento); color: var(--acento-txt); padding: 6px 22px; font-size: .85rem; }

/* blocos */
.cartao { background: var(--painel); border: 1px solid var(--borda); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.cartao.estreito { max-width: 560px; margin: 6vh auto; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--painel); border: 1px solid var(--borda); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.card small { color: var(--sutil); }
.card b { font-size: 1.25rem; }
.sutil { color: var(--sutil); font-size: .9rem; }
.grande { font-size: 1.1rem; }
.aviso { background: var(--painel2); border-left: 3px solid var(--acento); padding: 10px 12px; border-radius: 6px; }
.linha { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grade2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--borda); vertical-align: top; }
th { color: var(--sutil); font-weight: 600; }
.cartao table { display: block; overflow-x: auto; }
.cartao table tbody, .cartao table thead { display: table; width: 100%; table-layout: auto; }

/* botões e formulários */
.btn { background: var(--acento); color: var(--acento-txt); border: 0; border-radius: 9px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secundario { background: var(--painel2); color: var(--texto); border: 1px solid var(--borda); }
.btn.fantasma { background: transparent; color: var(--texto); border: 1px solid var(--borda); }
.btn.pequeno { padding: 6px 10px; font-size: .85rem; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: .92rem; }
input, select, textarea { font: inherit; color: var(--texto); background: var(--painel2); border: 1px solid var(--borda); border-radius: 8px; padding: 9px 10px; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; }
fieldset { border: 1px solid var(--borda); border-radius: 10px; padding: 10px 12px; margin: 0; }
legend { padding: 0 6px; color: var(--sutil); font-size: .9rem; }
.form label.op { flex-direction: row; align-items: center; gap: 8px; }
.chip { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 6px; background: var(--painel2); border: 1px solid var(--borda); border-radius: 20px; padding: 5px 11px; }
.filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin-bottom: 8px; }

/* progresso */
.barra { height: 8px; background: var(--painel2); border-radius: 6px; overflow: hidden; margin: 6px 0; }
.barra span { display: block; height: 100%; background: var(--acento); transition: width .3s; }
.barras { display: flex; gap: 6px; align-items: flex-end; height: 150px; padding-top: 6px; }
.barras .col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.barras .col span { width: 100%; max-width: 34px; background: var(--acento); border-radius: 4px 4px 0 0; min-height: 2px; }
.barras .col span.vazio { background: var(--borda); }
.barras .col small { font-size: .7rem; color: var(--sutil); }
.badge { background: var(--erro); color: #fff; border-radius: 10px; padding: 0 7px; font-size: .75rem; }

/* tags */
.tag { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.tag.oficial { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); }
.tag.inedita { background: color-mix(in srgb, var(--ined) 18%, transparent); color: var(--ined); }
.tag.aviso { background: color-mix(in srgb, var(--acento) 20%, transparent); color: var(--acento); }
.tag.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.chip-n { font-size: .8rem; padding: 2px 8px; border-radius: 10px; background: var(--painel2); white-space: nowrap; }
.chip-n.n1, .chip-n.n2 { color: var(--erro); }
.chip-n.n3 { color: var(--acento); }
.chip-n.n4, .chip-n.n5 { color: var(--ok); }
.st { font-size: .8rem; white-space: nowrap; }
.st.dominado { color: var(--ok); }
.st.precisa-revisar { color: var(--erro); }

/* questão */
.questao .q-cab { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.enunciado { font-size: 1.02rem; white-space: pre-line; }
.ctx { background: var(--painel2); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: .92rem; }
.ctx p { white-space: pre-line; }
.opcoes { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.opcoes.ce { flex-direction: row; flex-wrap: wrap; }
.op-btn { text-align: left; font: inherit; color: var(--texto); background: var(--painel2); border: 1px solid var(--borda); border-radius: 9px; padding: 10px 14px; cursor: pointer; }
.op-btn:hover:not(:disabled) { border-color: var(--acento); }
.op-btn.sel { border-color: var(--acento); box-shadow: inset 0 0 0 1px var(--acento); }
.op-btn.branco { color: var(--sutil); }
.op-btn:disabled { cursor: default; }
.op-btn b { margin-right: 6px; }
.chute { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--sutil); margin-bottom: 10px; }
.feedback { margin-top: 12px; }
.feedback.certo { border-left: 3px solid var(--ok); padding-left: 12px; }
.feedback.errado { border-left: 3px solid var(--erro); padding-left: 12px; }
.feedback.neutro { border-left: 3px solid var(--sutil); padding-left: 12px; }
.gab { border-top: 1px solid var(--borda); padding-top: 10px; margin-top: 10px; }

/* plano */
.semana { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.dia { margin: 0; }
.dia.hoje { border-color: var(--acento); }
.dia h3 small { color: var(--sutil); font-weight: 400; }
.dia ol, .missao { padding-left: 20px; margin: 0; }
.dia li, .missao li { margin-bottom: 8px; font-size: .92rem; }

/* vídeo */
.video { margin-bottom: 18px; }
.embed { position: relative; padding-top: 56.25%; border-radius: 10px; overflow: hidden; background: #000; margin: 8px 0; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* avisos */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 40; }
.toast { background: var(--painel); border: 1px solid var(--borda); border-left: 4px solid var(--info); padding: 10px 14px; border-radius: 8px; max-width: 340px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.ok { border-left-color: var(--ok); }
.toast.erro { border-left-color: var(--erro); }
.carregando { color: var(--sutil); }

/* celular */
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .lateral { width: auto; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--borda); padding: 10px; gap: 8px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .nav a { white-space: nowrap; padding: 6px 10px; background: var(--painel2); }
  .nav .sair { margin-top: 0; }
  .lateral-pe { flex-direction: row; align-items: center; justify-content: space-between; }
  .topo { padding: 8px 12px; flex-wrap: wrap; }
  .conteudo { padding: 14px; }
  .grade2 { grid-template-columns: 1fr; }
  .cartao { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* questão comentada */
.coment { background: var(--painel2); border-radius: 10px; padding: 10px 14px; margin: 8px 0; }
.coment h4 { margin: 0 0 6px; font-size: .95rem; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.alts { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.alts li { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--borda); }
.alts li.certa { border-color: var(--ok); }
