:root {
  --fundo: #f6f5f1;
  --cartao: #ffffff;
  --texto: #17181c;
  --suave: #6b6d76;
  --linha: #e7e5df;
  --acento: #4f5bff;
  --acento-suave: #eceeff;
  --bom: #1f9d63;
  --bom-suave: #e5f6ee;
  --mau: #e0483e;
  --mau-suave: #fdeceb;
  --aviso: #c98a0d;
  --raio: 16px;
  --sombra: 0 1px 2px rgba(20, 20, 30, .05), 0 4px 16px rgba(20, 20, 30, .05);
  --topo: env(safe-area-inset-top, 0px);
  --base: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #14151a; --cartao: #1d1f26; --texto: #f1f1f4; --suave: #9a9caa;
    --linha: #2b2e38; --acento: #7c86ff; --acento-suave: #262a4a;
    --bom: #39c487; --bom-suave: #183528; --mau: #ff6b61; --mau-suave: #3a1f1d;
    --sombra: none;
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--fundo); color: var(--texto); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; overscroll-behavior-y: none; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
input, select, textarea { font-size: 16px; } /* evita zoom no iPhone */
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(84px + var(--base)); }
.arranque { min-height: 100dvh; display: grid; place-items: center; }
.mascote { width: 140px; height: auto; display: block; margin: 0 auto; filter: drop-shadow(0 6px 14px rgba(20,20,30,.12)); }
.arranque .mascote { width: 120px; animation: respira 1.6s ease-in-out infinite; }
@keyframes respira { 50% { transform: scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .arranque .mascote { animation: none; } }
.logo-grande { width: 72px; height: 72px; border-radius: 22px; background: var(--acento); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 36px; letter-spacing: -1px; }

/* topo */
.topo { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--fundo) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); padding: calc(10px + var(--topo)) 18px 10px; display: flex; align-items: center; gap: 10px; min-height: 56px; }
.topo h1 { font-size: 20px; font-weight: 750; letter-spacing: -.3px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voltar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; margin-left: -8px; }
.voltar:active { background: var(--linha); }

.pag { padding: 6px 18px 24px; display: flex; flex-direction: column; gap: 14px; }
.titulo-sec { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .6px; color: var(--suave); margin: 10px 2px -4px; }
.saudacao { font-size: 28px; font-weight: 800; letter-spacing: -.6px; padding: calc(18px + var(--topo)) 18px 0; }
.sub { color: var(--suave); font-size: 15px; padding: 2px 18px 0; }

/* cartões */
.cartao { background: var(--cartao); border-radius: var(--raio); box-shadow: var(--sombra); padding: 16px; border: 1px solid var(--linha); }
.cartao.toque { transition: transform .12s ease; }
.cartao.toque:active { transform: scale(.98); }
.disc { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; }
.bola { width: 44px; height: 44px; border-radius: 14px; flex: none; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; }
.disc .info { flex: 1; min-width: 0; }
.disc .nome { font-weight: 650; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disc .meta { color: var(--suave); font-size: 13.5px; }
.disc .nota { font-size: 24px; font-weight: 800; letter-spacing: -.5px; min-width: 48px; text-align: right; }

.hoje { display: flex; gap: 10px; }
.hoje .cartao { flex: 1; padding: 14px; }
.num { font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.rot { color: var(--suave); font-size: 13px; }

/* botões */
.btn { min-height: 48px; border-radius: 14px; padding: 0 18px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--acento); color: #fff; transition: transform .1s ease, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.sec { background: var(--acento-suave); color: var(--acento); }
.btn.fantasma { background: transparent; color: var(--acento); }
.btn.perigo { background: var(--mau-suave); color: var(--mau); }
.btn.cheio { width: 100%; }
.btn.peq { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 11px; }
.fila { display: flex; gap: 8px; flex-wrap: wrap; }
.fila .btn { flex: 1 1 auto; }

/* separadores */
.seg { display: flex; background: var(--linha); border-radius: 13px; padding: 3px; gap: 2px; margin: 0 18px; position: sticky; top: calc(56px + var(--topo)); z-index: 4; }
.seg button { flex: 1; min-height: 38px; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--suave); }
.seg button[aria-selected="true"] { background: var(--cartao); color: var(--texto); box-shadow: var(--sombra); }

/* navegação inferior */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: color-mix(in srgb, var(--cartao) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--linha); display: flex; justify-content: center; padding-bottom: var(--base); }
.nav .in { display: flex; width: 100%; max-width: 560px; }
.nav a { flex: 1; text-decoration: none; color: var(--suave); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 0 8px; font-size: 11.5px; font-weight: 600; }
.nav a .ic { font-size: 21px; line-height: 1; }
.nav a[aria-current="page"] { color: var(--acento); }

/* formulários */
label.campo { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--suave); }
.inp { width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--linha); background: var(--cartao); padding: 10px 14px; color: var(--texto); }
.inp:focus { border-color: var(--acento); outline: none; }
textarea.inp { min-height: 90px; resize: vertical; }
.ajuda { color: var(--suave); font-size: 13.5px; }
.erro-txt { color: var(--mau); font-size: 14px; }
.cores { display: flex; gap: 10px; flex-wrap: wrap; }
.cores button { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; }
.cores button[aria-pressed="true"] { border-color: var(--texto); }
.dom-linha { display: grid; grid-template-columns: 1fr 84px 40px; gap: 8px; align-items: center; }

/* folha (modal) */
.vela { position: fixed; inset: 0; background: rgba(0,0,0,.38); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: aparecer .18s ease; }
.folha { background: var(--fundo); width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; border-radius: 22px 22px 0 0; padding: 10px 18px calc(22px + var(--base)); display: flex; flex-direction: column; gap: 14px; animation: subir .26s cubic-bezier(.2,.8,.2,1); overscroll-behavior: contain; }
.folha .pega { width: 38px; height: 5px; border-radius: 3px; background: var(--linha); align-self: center; margin-bottom: 4px; }
.folha h2 { font-size: 20px; font-weight: 750; }
@keyframes subir { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .vela, .folha, .flip-in { animation: none !important; } .cartao.toque, .btn { transition: none; } }

/* listas */
.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--linha); }
.item:last-child { border-bottom: 0; }
.item .tx { flex: 1; min-width: 0; }
.item .t1 { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t2 { color: var(--suave); font-size: 13.5px; }
.chk { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--linha); flex: none; display: grid; place-items: center; font-size: 15px; color: #fff; }
.chk[aria-checked="true"] { background: var(--acento); border-color: var(--acento); }
.etq { font-size: 12px; font-weight: 650; padding: 3px 8px; border-radius: 8px; background: var(--acento-suave); color: var(--acento); white-space: nowrap; }
.vazio { text-align: center; color: var(--suave); padding: 22px 10px; }
.vazio .grande { font-size: 34px; margin-bottom: 6px; }

/* notas */
.final { text-align: center; padding: 20px 16px; }
.final .grande { font-size: 56px; font-weight: 850; letter-spacing: -2px; line-height: 1; }
.barra { height: 8px; border-radius: 4px; background: var(--linha); overflow: hidden; margin-top: 6px; }
.barra i { display: block; height: 100%; background: var(--acento); border-radius: 4px; }
.dom { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.dom b { font-size: 18px; }

/* resumo */
.resumo h3 { font-size: 17px; margin: 14px 0 6px; }
.resumo li { margin: 0 0 8px 18px; }
.fonte { display: inline-block; font-size: 11.5px; font-weight: 650; color: var(--acento); background: var(--acento-suave); border-radius: 6px; padding: 1px 6px; margin-left: 4px; vertical-align: 1px; }
.conceito { padding: 10px 0; border-bottom: 1px solid var(--linha); }

/* flashcard */
.flash { min-height: 260px; display: flex; flex-direction: column; justify-content: center; text-align: center; font-size: 19px; font-weight: 600; padding: 28px 20px; }
.flash .lado { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--suave); margin-bottom: 12px; font-weight: 700; }
.flip-in { animation: flip .22s ease; }
@keyframes flip { from { transform: rotateX(70deg); opacity: .3; } to { transform: none; opacity: 1; } }

/* quiz */
.opcao { text-align: left; width: 100%; padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--linha); background: var(--cartao); font-weight: 550; min-height: 52px; }
.opcao.certa { border-color: var(--bom); background: var(--bom-suave); }
.opcao.errada { border-color: var(--mau); background: var(--mau-suave); }
.progresso { height: 6px; border-radius: 3px; background: var(--linha); overflow: hidden; }
.progresso i { display: block; height: 100%; background: var(--acento); transition: width .25s ease; }

/* plano */
.dia { padding: 12px 0; border-bottom: 1px solid var(--linha); }
.dia.hoje-d { background: var(--acento-suave); margin: 0 -16px; padding: 12px 16px; border-radius: 12px; border: 0; }
.dia .d { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.dia ul { margin-left: 18px; }

/* carregamento */
.carregar { position: fixed; inset: 0; z-index: 30; background: color-mix(in srgb, var(--fundo) 85%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: grid; place-items: center; animation: aparecer .2s ease; }
.carregar .cx { text-align: center; padding: 24px; max-width: 300px; }
.roda { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--linha); border-top-color: var(--acento); animation: rodar .8s linear infinite; margin: 0 auto 14px; }
@keyframes rodar { to { transform: rotate(360deg); } }
.esqueleto { height: 72px; border-radius: var(--raio); background: linear-gradient(90deg, var(--linha) 25%, var(--cartao) 50%, var(--linha) 75%); background-size: 200% 100%; animation: brilho 1.2s infinite; }
@keyframes brilho { to { background-position: -200% 0; } }

#toast { position: fixed; left: 50%; bottom: calc(96px + var(--base)); transform: translateX(-50%) translateY(20px); background: var(--texto); color: var(--fundo); padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 40; max-width: calc(100% - 36px); text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

.auth { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: calc(24px + var(--topo)) 22px calc(24px + var(--base)); gap: 16px; max-width: 420px; margin: 0 auto; }
.auth h1 { font-size: 32px; font-weight: 850; letter-spacing: -1px; }
.demo-banner { background: var(--acento-suave); color: var(--acento); font-size: 13px; font-weight: 600; text-align: center; padding: calc(6px + var(--topo)) 12px 6px; }
.oculto { display: none !important; }
a.lnk { color: var(--acento); font-weight: 600; text-decoration: none; }

/* ---------- Texugui v2: chat, explicações interativas, simulados ---------- */
.perguntar { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--acento-suave); border-color: transparent; }
.perguntar .tx { flex: 1; }
.perguntar .tx b { font-size: 17px; }
.perguntar .cam { font-size: 24px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--acento); }
.mascote-mini { width: 46px; height: 44px; object-fit: contain; }
.chip-sel { border: 1px solid var(--linha); background: var(--cartao); border-radius: 999px; padding: 6px 10px; font-size: 14px; max-width: 42vw; }
.pag.chat { padding-bottom: calc(196px + var(--base)); gap: 10px; }
.chat-vazio { text-align: center; padding: 24px 6px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.chat-vazio h2 { font-size: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chips.centro { justify-content: center; }
.chip { border: 1px solid var(--linha); background: var(--cartao); color: var(--texto); border-radius: 999px; padding: 8px 12px; font-size: 14px; font-weight: 600; min-height: 38px; }
.chip:active { transform: scale(.97); }
.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg.eu { justify-content: flex-end; }
.msg .col { display: flex; flex-direction: column; max-width: calc(100% - 44px); }
.avatar { width: 34px; height: 33px; object-fit: contain; flex: none; }
.bolha { border-radius: 18px; padding: 11px 14px; max-width: 86%; overflow-wrap: anywhere; animation: aparecer .2s ease-out; }
.msg .col .bolha { max-width: 100%; }
.bolha.eu { background: var(--acento); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.bolha.ia { background: var(--cartao); border: 1px solid var(--linha); border-bottom-left-radius: 6px; }
.bolha.ia.erro { color: var(--mau); }
.bolha .fotos { display: flex; gap: 6px; margin-bottom: 6px; }
.bolha .fotos img { width: 120px; height: 120px; object-fit: cover; border-radius: 12px; }
.foto-ph { font-size: 13px; opacity: .85; }
.rico p { margin: 0 0 8px; }
.rico p:last-child { margin-bottom: 0; }
.rico-ul { margin: 4px 0 8px 18px; }
.rico-ul li { margin: 3px 0; }
.rot-mini { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--acento); margin: 12px 0 6px; }
.passos { margin: 0 0 8px 20px; }
.passos li { margin: 6px 0; }
.passo-in { animation: aparecer .25s ease-out; }
.teste-rapido { border-top: 1px dashed var(--linha); margin-top: 10px; padding-top: 2px; }
.teste-rapido .t1 { font-weight: 650; margin-bottom: 8px; }
.opcao.peq { padding: 10px 12px; font-size: 15px; margin-bottom: 6px; }
.escrever { display: inline-flex; gap: 4px; padding: 4px 2px; }
.escrever i { width: 7px; height: 7px; border-radius: 50%; background: var(--suave); animation: pulsar 1s infinite ease-in-out; }
.escrever i:nth-child(2) { animation-delay: .15s; }
.escrever i:nth-child(3) { animation-delay: .3s; }
@keyframes pulsar { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
.ctx { font-size: 13px; color: var(--suave); background: var(--acento-suave); border-radius: 12px; padding: 8px 10px; }
.ctx .lnk { margin-left: 6px; color: var(--acento); font-weight: 700; }
.composer { position: fixed; left: 0; right: 0; bottom: calc(58px + var(--base)); z-index: 9; padding: 8px 12px; background: color-mix(in srgb, var(--fundo) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); max-width: 560px; margin: 0 auto; }
.composer .linha { display: flex; align-items: flex-end; gap: 8px; }
.chat-inp { flex: 1; resize: none; border: 1px solid var(--linha); background: var(--cartao); border-radius: 20px; padding: 10px 14px; min-height: 44px; max-height: 140px; line-height: 1.35; }
.chat-inp:focus { outline: none; border-color: var(--acento); }
.chat-ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: var(--cartao); border: 1px solid var(--linha); flex: none; }
.chat-ic.enviar { background: var(--acento); color: #fff; border: 0; }
.chat-ic[disabled] { opacity: .5; }
.thumbs { display: flex; gap: 8px; }
.thumbs:not(:empty) { margin-bottom: 8px; }
.thumb { position: relative; width: 58px; height: 58px; border-radius: 12px; overflow: hidden; background: var(--cartao); border: 1px solid var(--linha); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 15px; line-height: 1; }
.relogio { position: sticky; top: calc(56px + var(--topo)); z-index: 4; align-self: center; background: var(--cartao); border: 1px solid var(--linha); border-radius: 999px; padding: 6px 14px; font-weight: 750; font-variant-numeric: tabular-nums; box-shadow: var(--sombra); }
.relogio.pouco { color: var(--mau); border-color: var(--mau); }
.questao p { margin: 8px 0 10px; }
.opcao.escolhida { border-color: var(--acento); background: var(--acento-suave); }
.opcao.fixa { cursor: default; }
.etq.bom { color: var(--bom); }
.etq.mau { color: var(--mau); }
.resp-aluno { white-space: pre-wrap; background: var(--fundo); border-radius: 12px; padding: 10px 12px; font-size: 15px; margin-bottom: 8px; }
@media (prefers-reduced-motion: reduce) { .bolha, .passo-in, .escrever i { animation: none; } }
.questao .opcao { margin-bottom: 8px; }
.msg.ia { align-items: flex-start; }

/* ---------- v3: modos de estudo, temas a rever, desempenho ---------- */
.modos { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.modos::-webkit-scrollbar { display: none; }
.chip.modo { white-space: nowrap; flex: none; min-height: 34px; padding: 6px 11px; font-size: 13px; }
.chip.modo[aria-pressed="true"], .modo-cartao[aria-pressed="true"] { border-color: var(--acento); background: var(--acento-suave); color: var(--acento); }
.modos-grandes { display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left; margin-top: 6px; }
.modo-cartao { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; border: 1.5px solid var(--linha); background: var(--cartao); width: 100%; text-align: left; }
.modo-cartao .ic { font-size: 24px; width: 32px; text-align: center; }
.modo-cartao .tx { display: flex; flex-direction: column; gap: 2px; }
.modo-cartao b { font-size: 16px; }
.item.tema { gap: 6px; flex-wrap: wrap; }
.item.tema .tx { min-width: 120px; }
.desemp { display: block; width: 100%; text-align: left; padding: 9px 0; border-bottom: 1px solid var(--linha); }
.desemp:last-of-type { border-bottom: 0; }
.desemp .t1 { font-weight: 650; }
.barra2 { position: relative; height: 10px; border-radius: 5px; background: var(--linha); margin-top: 7px; }
.barra2 i { display: block; height: 100%; border-radius: 5px; background: var(--acento); }
.barra2.bom i { background: var(--bom); }
.barra2.aviso i { background: var(--aviso); }
.barra2.mau i { background: var(--mau); }
.barra2 .alvo { position: absolute; top: -4px; width: 3px; height: 18px; border-radius: 2px; background: var(--texto); transform: translateX(-1px); }
.aviso-cx { border-color: var(--aviso); }
button.etq { border: 0; cursor: pointer; }
.item.tema { flex-wrap: nowrap; }
.item.tema .tx { min-width: 0; flex: 1; }
.item.tema .t1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.tema .btn.peq { padding: 0 9px; min-height: 34px; font-size: 13px; }
.item.tema .voltar { width: 34px; height: 34px; flex: none; }
.nowrap { white-space: nowrap; }
