/* ═══ base: reset, tipografia, movimento, primitivas ═══ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--bg); color: var(--txt);
  font: 400 var(--t-17)/1.45 var(--f-texto);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
h1, h2, h3, p { margin: 0; }
h1, h2, .display { font-family: var(--f-display); letter-spacing: -.02em; text-wrap: balance; }
h1 { font-size: var(--t-28); font-weight: 700; line-height: 1.15; }
h2 { font-size: var(--t-22); font-weight: 600; line-height: 1.2; }
.n { font-family: var(--f-display); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.n-34 { font-size: var(--t-34); line-height: 1; }
.n-28 { font-size: var(--t-28); line-height: 1; }
.n-22 { font-size: var(--t-22); line-height: 1; }
.t-15 { font-size: var(--t-15); }
.t-13 { font-size: var(--t-13); }
.t-2 { color: var(--txt-2); }
.t-3 { color: var(--txt-3); }
.rotulo { font-size: var(--t-11); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--txt-3); }
.tab { font-variant-numeric: tabular-nums; }
a { color: var(--acc); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, select, textarea { font: inherit; color: inherit; }
img, svg, video, canvas { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:where(button, a, input, select, textarea, [tabindex]):focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; border-radius: var(--r-s); }

/* ícones (sprite Lucide, traço 1.75) */
.ic { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic-20 { width: 20px; height: 20px; }
.ic-16 { width: 16px; height: 16px; }

/* ── telas ── */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.tela { display: none; flex: 1; width: 100%; max-width: var(--col, var(--col-aluno)); margin: 0 auto; padding: calc(var(--s-8) + var(--sa-t)) var(--s-4) calc(var(--aba-h) + var(--sa-b) + var(--s-6)); }
.tela.ativa { display: block; animation: entra var(--d-tela) var(--mola) both; }
@keyframes entra { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.tela > * + * { margin-top: var(--s-6); }
.bloco > * + * { margin-top: var(--s-3); }
.aparece { animation: entra var(--d-tela) var(--mola) both; }

/* ── botões: primário (um por tela), secundário, ícone ── */
.bt {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 52px; padding: 0 var(--s-5); border-radius: var(--r-pill);
  font-weight: 600; font-size: var(--t-17);
  background: var(--acc); color: var(--acc-txt);
  transition: transform var(--d-toque) var(--mola), opacity var(--d-toque);
}
.bt:active { transform: scale(.97); }
.bt:disabled { opacity: .4; cursor: default; }
.bt-largo { width: 100%; }
.bt-2 { background: var(--sup-2); color: var(--txt); }
.bt-3 { background: transparent; color: var(--acc); min-height: 44px; padding: 0 var(--s-3); }
.bt-ic { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; background: var(--sup-2); color: var(--txt); display: inline-grid; place-items: center; transition: transform var(--d-toque) var(--mola); }
.bt-ic:active { transform: scale(.94); }
.bt.ocupado { pointer-events: none; opacity: .7; }
.bt.ocupado::after { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: gira .7s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.acoes { display: flex; gap: var(--s-3); flex-wrap: wrap; }

/* ── campos ── */
.campo { display: grid; gap: var(--s-2); }
.campo label { font-size: var(--t-13); font-weight: 500; color: var(--txt-2); }
.campo input, .campo select {
  width: 100%; min-height: 48px; padding: 0 var(--s-4);
  background: var(--sup); border: 1px solid var(--sep); border-radius: var(--r);
  transition: border-color var(--d-toque);
}
.campo input:focus-visible, .campo select:focus-visible { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-soft); }
.campo input::placeholder { color: var(--txt-3); }
.campo select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 40px; }
.campo .dica { font-size: var(--t-13); color: var(--txt-3); }
.form > * + * { margin-top: var(--s-5); }
.linha-2 { display: grid; gap: var(--s-4); grid-template-columns: 1fr 1fr; }

/* erro inline: aparece só quando há erro */
.erro { display: none; font-size: var(--t-15); color: var(--erro); }
.erro.mostra { display: block; animation: entra var(--d-tela) var(--mola) both; }

/* ── lista agrupada (iOS) ── */
.lista { background: var(--sup); border-radius: var(--r); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: var(--s-3); min-height: 56px;
  padding: var(--s-3) var(--s-4); width: 100%; text-align: left;
  border-bottom: 1px solid var(--sep); transition: background var(--d-toque);
}
.item:last-child { border-bottom: 0; }
button.item:active { background: var(--sup-2); }
.item-txt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.item-txt b { font-weight: 500; font-size: var(--t-17); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-txt span { font-size: var(--t-13); color: var(--txt-2); }
.item-dir { flex: none; font-size: var(--t-15); color: var(--txt-2); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: var(--s-2); }
.item-dir .ic { color: var(--txt-3); }

/* ── segmentado e chips ── */
.seg { display: flex; padding: 3px; background: var(--sup-2); border-radius: var(--r-s); }
.seg button { flex: 1; min-height: 40px; border-radius: 8px; font-size: var(--t-15); font-weight: 500; color: var(--txt-2); transition: background var(--d-toque), color var(--d-toque); }
.seg button[aria-pressed="true"] { background: var(--sup); color: var(--txt); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { min-height: 40px; padding: 0 var(--s-4); border-radius: var(--r-pill); background: var(--sup); border: 1px solid var(--sep); font-size: var(--t-15); font-weight: 500; transition: border-color var(--d-toque), background var(--d-toque), color var(--d-toque); }
.chip[aria-pressed="true"] { background: var(--acc-soft); border-color: var(--acc); color: var(--acc); }
.tag { display: inline-flex; align-items: center; min-height: 28px; padding: 0 var(--s-3); border-radius: var(--r-pill); background: var(--sup-2); font-size: var(--t-13); font-weight: 500; color: var(--txt-2); }

/* ── barra de abas (aluno) ── */
.abas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  padding-bottom: var(--sa-b);
  background: var(--vidro); backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-top: 1px solid var(--sep);
}
.abas-in { display: flex; width: 100%; max-width: var(--col-aluno); height: var(--aba-h); }
.aba { flex: 1; display: grid; justify-items: center; align-content: center; gap: 3px; color: var(--txt-3); font-size: var(--t-11); font-weight: 500; transition: color var(--d-toque); }
.aba[aria-current="page"] { color: var(--acc); }
.aba .ic { width: 26px; height: 26px; }

/* ── folha modal (sobe do rodapé) ── */
.veu { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity var(--d-folha); }
.veu.aberto { opacity: 1; pointer-events: auto; }
.folha {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  margin: 0 auto; max-width: var(--col-aluno);
  background: var(--sup); border-radius: var(--r-l) var(--r-l) 0 0;
  padding: var(--s-3) var(--s-5) calc(var(--s-6) + var(--sa-b));
  max-height: 88dvh; overflow-y: auto;
  transform: translateY(102%); transition: transform var(--d-folha) var(--mola);
  box-shadow: 0 -1px 0 var(--sep);
}
.folha.aberta { transform: none; }
.folha::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--sep); margin: 0 auto var(--s-4); }
.folha > * + * { margin-top: var(--s-4); }

/* ── aviso flutuante ── */
.aviso { position: fixed; left: 50%; bottom: calc(var(--aba-h) + var(--sa-b) + var(--s-4)); transform: translate(-50%, 12px); z-index: 50; padding: var(--s-3) var(--s-5); border-radius: var(--r-pill); background: var(--txt); color: var(--bg); font-size: var(--t-15); font-weight: 500; opacity: 0; pointer-events: none; transition: opacity var(--d-tela), transform var(--d-tela) var(--mola); white-space: nowrap; }
.aviso.mostra { opacity: 1; transform: translate(-50%, 0); }

/* ── esqueleto ── */
.esq { height: 14px; border-radius: 7px; background: var(--sup-2); position: relative; overflow: hidden; }
.esq::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(127,127,127,.18), transparent); animation: brilho 1.2s linear infinite; }
@keyframes brilho { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

@media (min-width: 720px) {
  .tela { padding-inline: var(--s-6); }
}
@media (prefers-reduced-motion: reduce) {
  .tela.ativa, .aparece, .erro.mostra { animation: none; }
  .esq::after { animation: none; }
}

/* ── tema: sol ↔ lua no canto superior direito ── */
.tema { position: fixed; top: calc(var(--s-3) + var(--sa-t)); right: var(--s-4); z-index: 35; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--txt-2); transition: transform var(--d-volta) var(--retorno), color 250ms; }
.tema:active { transform: scale(.9); transition-duration: var(--d-toque); }
.tema svg { width: 22px; height: 22px; overflow: visible; }
.tema .nucleo { fill: currentColor; r: 5px; transition: r var(--d-volta) var(--retorno); }
.tema .raios { stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; transform-origin: 12px 12px; transition: transform var(--d-volta) var(--retorno), opacity 180ms; }
.tema .mascara-c { cx: 30px; cy: -4px; transition: cx 260ms var(--mola), cy 260ms var(--mola); }
:root[data-tema-efetivo="escuro"] .tema .nucleo { r: 8.5px; }
:root[data-tema-efetivo="escuro"] .tema .raios { transform: scale(0) rotate(45deg); opacity: 0; }
:root[data-tema-efetivo="escuro"] .tema .mascara-c { cx: 17px; cy: 7px; }
body.em-camera .tema { display: none; }

/* revelação circular a partir do ícone (View Transitions) */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }
/* sem View Transitions: crossfade curto */
html.crossfade, html.crossfade body, html.crossfade .tela, html.crossfade .lista, html.crossfade .item, html.crossfade .questao, html.crossfade .msg, html.crossfade .bt, html.crossfade .alt, html.crossfade .abas, html.crossfade .folha, html.crossfade .continuar, html.crossfade .des-alt, html.crossfade .mini .quadro { transition: background-color 250ms ease, color 250ms ease, border-color 250ms ease; }

/* o sol/lua some enquanto o conteúdo está rolado */
.rolado .tema { opacity: 0; pointer-events: none; transform: translateY(-8px); }
.tema { transition: transform var(--d-volta) var(--retorno), color 250ms, opacity 200ms; }
