:root {
  --fundo: #f6f7fb;
  --cartao: #ffffff;
  --texto: #1f2330;
  --suave: #6b7183;
  --borda: #e4e6ef;
  --pri: #4f46e5;
  --pri-claro: #eef0ff;
  --ok: #16a34a;
  --ok-claro: #e8f8ee;
  --quase: #d97706;
  --quase-claro: #fff5e6;
  --erro: #dc2626;
  --erro-claro: #fdecec;
  --sombra: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 16px rgba(20, 24, 40, .05);
  --raio: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #12141c; --cartao: #1b1e29; --texto: #eceef5; --suave: #9aa0b4; --borda: #2c3040;
    --pri: #818cf8; --pri-claro: #262a45; --ok: #4ade80; --ok-claro: #17301f; --quase: #fbbf24; --quase-claro: #33280f;
    --erro: #f87171; --erro-claro: #3a1a1a; --sombra: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fundo); color: var(--texto); }
a { color: var(--pri); text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: .3rem 0 .8rem; }
small, .suave { color: var(--suave); }

.topo { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--cartao); border-bottom: 1px solid var(--borda); }
.marca { color: var(--texto); font-size: 1.1rem; display: flex; gap: 6px; align-items: center; }
.marca b { color: var(--pri); }
.topo-dir { display: flex; gap: 10px; align-items: center; }
.pill { font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--pri-claro); color: var(--pri); }
.menu-conta { position: relative; }
.menu-conta summary { list-style: none; cursor: pointer; width: 34px; height: 34px; border-radius: 50%; background: var(--pri); color: #fff; display: grid; place-items: center; font-weight: 700; }
.menu-conta summary::-webkit-details-marker { display: none; }
.menu-conta > div { position: absolute; right: 0; top: 42px; background: var(--cartao); border: 1px solid var(--borda); border-radius: 12px; box-shadow: var(--sombra); padding: 10px; min-width: 220px; display: flex; flex-direction: column; gap: 2px; }
.menu-conta > div a, .menu-conta > div strong { padding: 8px 10px; border-radius: 8px; }
.menu-conta > div a { color: var(--texto); }
.menu-conta > div a:hover { background: var(--pri-claro); }

.abas { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: var(--cartao); border-top: 1px solid var(--borda); padding-bottom: env(safe-area-inset-bottom); }
.abas a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 7px 0 6px; font-size: .7rem; color: var(--suave); position: relative; }
.abas a span { font-size: 1.25rem; line-height: 1.2; }
.abas a.ativo { color: var(--pri); font-weight: 700; }
.abas .bolinha { position: absolute; top: 4px; right: calc(50% - 20px); background: var(--erro); color: #fff; font-size: .65rem; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
@media (min-width: 900px) {
  .abas { position: sticky; top: 55px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--borda); justify-content: center; }
  .abas a { flex: 0 0 120px; flex-direction: row; gap: 6px; justify-content: center; font-size: .9rem; padding: 10px 0; }
  .abas a span { font-size: 1rem; }
}

.conteudo { max-width: 860px; margin: 0 auto; padding: 18px 16px 100px; }
.conteudo.solto { max-width: 420px; padding-top: 8vh; }

.cartao { background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); padding: 18px; box-shadow: var(--sombra); margin-bottom: 14px; }
.grade { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.linha { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.entre { justify-content: space-between; }

.botao, button { font: inherit; cursor: pointer; border: 0; border-radius: 12px; padding: 11px 18px; background: var(--pri); color: #fff; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; justify-content: center; text-align: center; }
.botao.sec, button.sec { background: var(--pri-claro); color: var(--pri); }
.botao.fant, button.fant { background: transparent; color: var(--suave); border: 1px solid var(--borda); }
.botao.grande, button.grande { padding: 15px 22px; font-size: 1.05rem; width: 100%; }
button:disabled { opacity: .5; cursor: default; }
.botao.ok, button.ok { background: var(--ok); }
.botao.perigo, button.perigo { background: var(--erro); }

label { display: block; font-weight: 600; margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=search], textarea, select {
  width: 100%; font: inherit; padding: 11px 13px; border: 1px solid var(--borda); border-radius: 12px; background: var(--cartao); color: var(--texto);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--pri); outline-offset: 1px; }

.aviso { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; background: var(--pri-claro); }
.aviso.ok { background: var(--ok-claro); color: var(--ok); }
.aviso.erro { background: var(--erro-claro); color: var(--erro); }
.aviso.quase { background: var(--quase-claro); color: var(--quase); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; }
.chip span { display: inline-block; padding: 8px 14px; border: 1px solid var(--borda); border-radius: 99px; cursor: pointer; font-weight: 500; }
.chip input:checked + span { background: var(--pri); color: #fff; border-color: var(--pri); }

.barra { height: 10px; background: var(--borda); border-radius: 99px; overflow: hidden; }
.barra > i { display: block; height: 100%; background: var(--pri); border-radius: 99px; transition: width .3s; }

.numero { font-size: 1.8rem; font-weight: 800; line-height: 1.1; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpis > div { background: var(--cartao); border: 1px solid var(--borda); border-radius: 14px; padding: 12px; text-align: center; }

.bloco { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--borda); border-radius: 14px; margin-bottom: 8px; color: var(--texto); background: var(--cartao); }
.bloco .min { width: 52px; text-align: center; font-weight: 800; color: var(--pri); flex: none; }
.bloco.feito { background: var(--ok-claro); border-color: transparent; }
.bloco.feito .min { color: var(--ok); }
.bloco .seta { margin-left: auto; color: var(--suave); }

/* Cartões de estudo */
.palco { text-align: center; }
.figura { font-size: 6rem; line-height: 1.1; margin: 8px 0; user-select: none; }
.palavra-en { font-size: 2rem; font-weight: 800; }
.opcoes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.opcoes button { background: var(--cartao); color: var(--texto); border: 2px solid var(--borda); padding: 14px 8px; font-size: 1.05rem; }
.opcoes button.certo { background: var(--ok-claro); border-color: var(--ok); color: var(--ok); }
.opcoes button.errado { background: var(--erro-claro); border-color: var(--erro); color: var(--erro); }
.retorno { margin-top: 14px; padding: 12px; border-radius: 12px; }
.retorno.certo { background: var(--ok-claro); color: var(--ok); }
.retorno.quase { background: var(--quase-claro); color: var(--quase); }
.retorno.errado { background: var(--erro-claro); color: var(--erro); }
.exemplo { font-style: italic; }
.ouvir { background: var(--pri-claro); color: var(--pri); border-radius: 50%; width: 44px; height: 44px; padding: 0; font-size: 1.2rem; }
.mic { width: 84px; height: 84px; border-radius: 50%; font-size: 2rem; padding: 0; }
.mic.gravando { background: var(--erro); animation: pulso 1s infinite; }
@keyframes pulso { 50% { box-shadow: 0 0 0 12px rgba(220, 38, 38, .15); } }
.relogio { font-size: 1.4rem; font-weight: 800; color: var(--pri); }
.relogio.acabando { color: var(--erro); }

/* Histórias */
.parte { font-size: 1.15rem; line-height: 1.7; }
.parte .frase { cursor: pointer; border-radius: 4px; }
.parte .frase:hover { background: var(--pri-claro); }
.serie { border-left: 5px solid var(--cor, var(--pri)); }
.ep { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--borda); color: var(--texto); }
.ep.travado { opacity: .5; pointer-events: none; }
.pergunta { margin-bottom: 14px; }
.pergunta .opcoes { grid-template-columns: 1fr; }
.pergunta .opcoes button { text-align: left; justify-content: flex-start; font-size: 1rem; padding: 11px 14px; }

/* Conversa */
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 40vh; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; }
.msg.ia { background: var(--cartao); border: 1px solid var(--borda); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.eu { background: var(--pri); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg .dica { display: block; margin-top: 6px; font-size: .85rem; color: var(--quase); }
.compor { position: sticky; bottom: 70px; background: var(--fundo); padding: 10px 0; display: flex; gap: 8px; align-items: flex-end; }
.compor textarea { min-height: 48px; height: 48px; }
@media (min-width: 900px) { .compor { bottom: 0; } }

table { width: 100%; border-collapse: collapse; }
td, th { padding: 8px 6px; border-bottom: 1px solid var(--borda); text-align: left; vertical-align: top; }
.nota { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; font-weight: 800; background: var(--pri-claro); color: var(--pri); }
.n4 { background: var(--ok-claro); color: var(--ok); } .n3 { background: #e7f5ff; color: #0369a1; }
.n1, .n0 { background: var(--erro-claro); color: var(--erro); } .n2 { background: var(--quase-claro); color: var(--quase); }
pre.resumo { white-space: pre-wrap; background: var(--fundo); border: 1px solid var(--borda); padding: 12px; border-radius: 12px; font-size: .85rem; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; background: var(--texto); color: var(--fundo); padding: 12px 18px; border-radius: 12px; z-index: 50; max-width: 90vw; box-shadow: var(--sombra); }
.selecionar-cartoes { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; max-height: 360px; overflow: auto; padding: 4px; }
.selecionar-cartoes label { margin: 0; font-weight: 400; text-align: center; border: 2px solid var(--borda); border-radius: 12px; padding: 6px 2px; cursor: pointer; font-size: .75rem; }
.selecionar-cartoes label span { display: block; font-size: 2rem; }
.selecionar-cartoes input { display: none; }
.selecionar-cartoes label:has(input:checked) { border-color: var(--pri); background: var(--pri-claro); }
.escondido { display: none !important; }
