/* ROI — identidade visual "Escola profissional" (modelo C, escolhido em 07/11/2026).
   Marinho + verde, fonte Lexend (hospedada no projeto, licença OFL), superfícies brancas com sombra leve,
   capas coloridas por módulo, poucos selos. Tema claro/escuro por variáveis. */
@font-face { font-family: "Lexend"; font-style: normal; font-weight: 300 700; font-display: swap; src: url(../fonts/lexend-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Lexend"; font-style: normal; font-weight: 300 700; font-display: swap; src: url(../fonts/lexend-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #eef1f6; --line: #e1e6ee; --line-2: #cdd5e1;
  --text: #14213d; --muted: #56627c;
  --brand: #00805a; --brand-2: #006347; --brand-soft: #e3f6ee; --fill: #00b37e; --fill-2: #00a070; --on-fill: #052a1e;
  --accent: #14213d; --accent-soft: #e8ecf4;
  --ok: #00805a; --ok-soft: #e3f6ee; --bad: #b42318; --bad-soft: #fdecea; --warn: #8a5300; --warn-soft: #fff3d6;
  --info: #2457c5; --info-soft: #eaf0fd;
  --top: #14213d; --top-text: #ffffff; --top-muted: #aab5cc; --top-line: #23304f;
  --m1: #00b37e; --m1-on: #052a1e; --m2: #ffb703; --m2-on: #3d2a00; --m3: #2563eb; --m3-on: #ffffff; --m4: #c2185b; --m4-on: #ffffff;
  --focus: #2563eb; --on-brand: #ffffff; --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20,33,61,.06), 0 4px 16px rgba(20,33,61,.06);
  --font: "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a101d; --surface: #111a2c; --surface-2: #18233a; --line: #243250; --line-2: #33446a;
    --text: #e9eef8; --muted: #9eabc6;
    --brand: #3ddc97; --brand-2: #7ae8b7; --brand-soft: #0e2c22; --fill: #00b37e; --fill-2: #19c48f; --on-fill: #052a1e;
    --accent: #e9eef8; --accent-soft: #1b2741;
    --ok: #3ddc97; --ok-soft: #0e2c22; --bad: #ff8a80; --bad-soft: #3a1714; --warn: #ffcf66; --warn-soft: #33270b;
    --info: #8fb3ff; --info-soft: #15244a;
    --top: #060b16; --top-text: #e9eef8; --top-muted: #8d9ab6; --top-line: #1a2540;
    --shadow: none; --on-brand: #052a1e; --focus: #8fb3ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a101d; --surface: #111a2c; --surface-2: #18233a; --line: #243250; --line-2: #33446a;
  --text: #e9eef8; --muted: #9eabc6;
  --brand: #3ddc97; --brand-2: #7ae8b7; --brand-soft: #0e2c22; --fill: #00b37e; --fill-2: #19c48f; --on-fill: #052a1e;
  --accent: #e9eef8; --accent-soft: #1b2741;
  --ok: #3ddc97; --ok-soft: #0e2c22; --bad: #ff8a80; --bad-soft: #3a1714; --warn: #ffcf66; --warn-soft: #33270b;
  --info: #8fb3ff; --info-soft: #15244a;
  --top: #060b16; --top-text: #e9eef8; --top-muted: #8d9ab6; --top-line: #1a2540;
  --shadow: none; --on-brand: #052a1e; --focus: #8fb3ff; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.65 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--brand-2); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 1.3em 0 .5em; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.8rem; margin-top: .2em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
p { margin: .5em 0 .85em; }
strong { font-weight: 600; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .05em .4em; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--fill); color: var(--on-fill); padding: 8px 12px; border-radius: 8px; z-index: 50; font-weight: 600; }
.skip:focus { left: 8px; }
.ico { width: 1.15em; height: 1.15em; vertical-align: -.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico .f, .ico.filled path { fill: currentColor; }

/* Cabeçalho */
.topbar { background: var(--top); color: var(--top-text); position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 0 var(--top-line); }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 10px 16px; display: flex; gap: 10px; align-items: center; }
.topbar .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--top-text); font-weight: 600; font-size: 1.2rem; letter-spacing: -.02em; }
.topbar .brand svg { flex: none; }
.topbar .brand .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--fill); margin-left: 2px; }
.topbar .brand small { display: block; font-weight: 300; font-size: .7rem; color: var(--top-muted); line-height: 1.2; letter-spacing: 0; }
.topbar .spacer { flex: 1; }
.iconbtn { white-space: nowrap; background: transparent; border: 0; color: var(--top-text); border-radius: 10px; padding: 8px 12px; cursor: pointer; font: inherit; font-size: .9rem; font-weight: 500; }
.iconbtn:hover { background: rgba(255,255,255,.1); }
.topbar :focus-visible { outline-color: #7ae8b7; }
.menu-toggle { display: none; }

/* Layout */
.layout { max-width: 1240px; margin: 0 auto; display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 28px; padding: 24px 16px 64px; }
.layout.full { grid-template-columns: minmax(0, 1fr); }
.sidenav { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 92px); overflow: auto; }
.sidenav .cert-title { font-weight: 600; padding: 4px 12px 10px; font-size: 1.05rem; }
.sidenav .cert-title small { display: block; font-weight: 400; color: var(--muted); font-size: .76rem; }
.sidenav ul { list-style: none; margin: 0; padding: 0; }
.sidenav a { display: block; padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--muted); font-size: .93rem; font-weight: 500; }
.sidenav a:hover { background: var(--surface); color: var(--text); }
.sidenav a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: inset 3px 0 0 var(--fill), var(--shadow); font-weight: 600; }
.sidenav .sep { border-top: 1px solid var(--line); margin: 10px 12px; }
main { min-width: 0; }
.page { max-width: 940px; }
.page.wide { max-width: none; }
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); text-decoration: underline; }

/* Componentes */
.card { background: var(--surface); border: 1px solid transparent; border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin: 0 0 18px; }
:root[data-theme="dark"] .card { border-color: var(--line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .card { border-color: var(--line); } }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--fill); background: var(--fill); color: var(--on-fill); padding: 9px 16px; border-radius: var(--radius-sm); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.3; min-height: 40px; }
.btn:hover { background: var(--fill-2); border-color: var(--fill-2); color: var(--on-fill); }
.btn.secondary { background: transparent; color: var(--text); border-color: var(--line-2); }
.btn.secondary:hover { background: var(--surface-2); color: var(--text); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); font-weight: 500; }
.btn.ghost:hover { background: var(--brand-soft); color: var(--brand-2); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.sm { padding: 5px 12px; font-size: .86rem; min-height: 32px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 500; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-2); }
.callout { background: var(--info-soft); color: var(--text); padding: 12px 16px; border-radius: var(--radius-sm); margin: 12px 0; }
.callout.warn { background: var(--warn-soft); }
.callout.ok { background: var(--ok-soft); }
.callout.bad { background: var(--bad-soft); }
.callout.brand { background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); }
.callout.small { padding: 9px 14px; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--fill); border-radius: 99px; }
.progress.mastery > span { background: var(--m3); }
.kpi { font-size: 2rem; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; }
.kpi-label { font-size: .82rem; color: var(--muted); }
.table-wrap { overflow-x: auto; margin: 12px 0; border-radius: var(--radius-sm); border: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 12px; text-align: left; vertical-align: top; }
tr:last-child > td { border-bottom: 0; }
th { background: var(--surface-2); font-weight: 600; font-size: .85rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain > li { padding: 10px 0; border-bottom: 1px solid var(--line); }
ul.plain > li:last-child { border-bottom: 0; }
details { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 14px; margin: 10px 0; background: var(--surface); }
details > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
label { font-weight: 500; font-size: .9rem; display: block; margin: 10px 0 5px; }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 9px 12px; width: 100%; max-width: 100%; min-height: 42px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--focus); }
textarea { min-height: 110px; resize: vertical; }
input[aria-invalid="true"] { border-color: var(--bad); }
.field-hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }
.field-error { font-size: .84rem; color: var(--bad); margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 4px 16px; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin: 8px 0 18px; }
.toolbar > div { min-width: 150px; flex: 1; }

/* Capas de módulo (uma cor por módulo da prova) */
.mod-cover { display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; border-radius: var(--radius-sm); padding: 14px 16px; min-height: 92px; background: var(--m1); color: var(--m1-on); text-decoration: none; }
.mod-cover .k { font-size: .74rem; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }
.mod-cover .t { font-size: 1.05rem; font-weight: 600; line-height: 1.25; }
.mod-cover.m2 { background: var(--m2); color: var(--m2-on); }
.mod-cover.m3 { background: var(--m3); color: var(--m3-on); }
.mod-cover.m4 { background: var(--m4); color: var(--m4-on); }
a.mod-cover:hover { filter: brightness(1.05); color: inherit; }
.mod-card { display: flex; flex-direction: column; gap: 10px; }
.mod-card .meta { display: flex; justify-content: space-between; font-size: .82rem; color: var(--muted); }
.eyebrow { font-size: .76rem; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); margin: 0 0 4px; }

/* Questões */
.q { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: var(--surface); margin: 14px 0; }
.q .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.q .context { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; margin: 6px 0 12px; font-size: .95rem; }
.q fieldset { border: 0; padding: 0; margin: 0; }
.q legend { font-weight: 600; margin-bottom: 10px; padding: 0; }
.opt { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 11px 14px; margin: 8px 0; cursor: pointer; font-weight: 400; transition: border-color .12s, background .12s; }
.opt:hover { border-color: var(--fill); background: var(--brand-soft); }
.opt input { margin-top: 5px; flex: none; accent-color: var(--fill); }
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt .why { display: block; font-size: .87rem; color: var(--muted); margin-top: 4px; }
.feedback { margin-top: 12px; }

/* Aula */
.lesson-nav { display: flex; gap: 4px; flex-wrap: wrap; margin: 10px 0 18px; padding: 4px; background: var(--surface-2); border-radius: 12px; }
.lesson-nav a { font-size: .84rem; padding: 6px 12px; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 500; }
.lesson-nav a:hover { background: var(--surface); color: var(--text); }
.section-title { display: flex; align-items: center; gap: 10px; padding-top: 6px; }
.section-title .num { width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: var(--text); display: inline-grid; place-items: center; font-size: .82rem; font-weight: 600; flex: none; }
.lesson-hero { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin: 14px 0 6px; }
.lesson-hero h2 { margin: 2px 0 10px; font-size: 1rem; }
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0b1220; border-radius: var(--radius-sm); overflow: hidden; }
.video-frame iframe, .video-frame > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.formula { font-family: var(--mono); background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; overflow-x: auto; white-space: pre; }

/* Catálogo */
.cert-card { display: flex; flex-direction: column; gap: 8px; }
.cert-card .short { font-size: 1.5rem; font-weight: 600; color: var(--text); letter-spacing: -.02em; }
.cert-card.soon { opacity: .8; }
.cert-card.soon .short { color: var(--muted); }

/* Flashcards */
.flash { min-height: 170px; display: grid; place-items: center; text-align: center; font-size: 1.1rem; padding: 24px; }

/* Diálogo de atendimento */
.chat { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 16px; }
.bubble.cliente { background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.prof { background: var(--brand-soft); align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble .who { font-size: .74rem; font-weight: 600; color: var(--muted); display: block; }
.bubble.narr { align-self: center; background: var(--warn-soft); font-style: italic; text-align: center; }

/* Gráfico */
.chart svg { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line-2); }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; }
.legend i { display: inline-block; width: 12px; height: 3px; vertical-align: middle; margin-right: 5px; }

.toast { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--top); color: var(--top-text); padding: 11px 18px; border-radius: 12px; z-index: 60; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: .92rem; }
.footer { max-width: 1240px; margin: 0 auto; padding: 22px 16px 40px; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }

/* Árvores de diálogo e cartões-link */
a.link-card { display: block; color: inherit; text-decoration: none; transition: box-shadow .15s, border-color .15s; }
a.link-card:hover, a.link-card:focus-visible { border-color: var(--fill); }
.dlg-step { border: 0; padding: 0; margin: 8px 0 0; }
.dlg-step legend { font-weight: 600; margin-bottom: 6px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding-top: 14px; gap: 16px; }
  .menu-toggle { display: inline-block; }
  .sidenav { position: static; max-height: none; display: none; border-radius: var(--radius); background: var(--surface); padding: 8px; box-shadow: var(--shadow); }
  .sidenav.open { display: block; }
  h1 { font-size: 1.5rem; }
  .topbar .brand small { display: none; }
  .card { padding: 16px; }
}
@media print { .topbar, .sidenav, .footer, .btn { display: none !important; } .layout { display: block; } .card { box-shadow: none; border: 1px solid #ccc; } }

/* App instalado (PWA): respeita o entalhe e a barra de gestos dos celulares. */
.topbar { padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.footer { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
#install-btn { background: var(--fill); color: var(--on-fill); }
#install-btn:hover { background: var(--fill-2); }
@media (max-width: 480px) { .iconbtn { padding-left: 9px; padding-right: 9px; } }

/* Estabilidade do layout (CLS): o atributo hidden sempre esconde; o botão Menu reserva seu espaço no celular;
   a área principal ocupa a tela, então o rodapé não "pula" quando a página termina de montar. */
[hidden]:not(.menu-toggle) { display: none !important; }
.menu-toggle[hidden] { visibility: hidden; }
#app { min-height: calc(100vh - 56px); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
/* Títulos recebem foco por programa ao trocar de página (para leitores de tela); sem moldura visual nesse caso. */
h1[tabindex="-1"]:focus, h2[tabindex="-1"]:focus, h3[tabindex="-1"]:focus { outline: none; }
