:root {
  --bg: #ffffff; --bg2: #f3f4f7; --card: #ffffff; --line: #e4e6ec;
  --text: #15181f; --muted: #6b7280; --accent: #b58900; --accent-bg: #fff6d6;
  --ok: #1a9e5a; --ok-bg: #e4f6ec; --warn: #d9880f; --warn-bg: #fff1dc;
  --bad: #d0453a; --bad-bg: #fde8e6;
  --radius: 16px; --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --bg2: #15181f; --card: #181b23; --line: #262a35;
    --text: #f2f3f7; --muted: #9aa1b2; --accent: #ffcf33; --accent-bg: #2a2410;
    --ok: #36c777; --ok-bg: #11301f; --warn: #f3a93b; --warn-bg: #352610;
    --bad: #f0665b; --bad-bg: #3a1a17;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%; }
body { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px)); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0;
  cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* ---------- topo ---------- */
.top { padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 10px; background: var(--bg);
  position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.title { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.updated { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.progresso-barra { height: 4px; background: var(--bg2); border-radius: 999px; margin-top: 12px; overflow: hidden; }
.progresso-barra > div { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .3s ease; }

/* ---------- base ---------- */
.view { padding: 10px 16px 28px; display: grid; gap: 14px; max-width: 640px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h2 { margin: 0 0 8px; font-size: 19px; line-height: 1.3; letter-spacing: -.01em; }
.card h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { text-align: center; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--bg2); color: var(--muted); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.acc { background: var(--accent-bg); color: var(--accent); }

/* ---------- card de estudo ---------- */
.q { font-size: 17px; line-height: 1.45; margin: 10px 0 16px; }
.opts { display: grid; gap: 8px; }
.opt { text-align: left; width: 100%; padding: 13px 14px; border-radius: 12px; background: var(--bg2);
  border: 1.5px solid transparent; font-size: 15px; line-height: 1.35; transition: background .12s, border-color .12s; }
.opt:active { background: var(--line); }
.opt.sel { border-color: var(--accent); background: var(--accent-bg); }
.opt.certa { border-color: var(--ok); background: var(--ok-bg); }
.opt.errada { border-color: var(--bad); background: var(--bad-bg); }
.opt .mark { font-weight: 700; margin-right: 6px; }

.verso { white-space: pre-line; font-size: 16px; line-height: 1.5; margin: 12px 0 0;
  padding: 14px; background: var(--bg2); border-radius: 12px; }

.regra { margin-top: 14px; padding: 13px 14px; border-radius: 12px;
  background: var(--accent-bg); border-left: 3px solid var(--accent); font-size: 15px; line-height: 1.45; }
.regra b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent); margin-bottom: 4px; }
.nota { margin-top: 10px; padding: 11px 13px; border-radius: 12px; background: var(--warn-bg);
  border-left: 3px solid var(--warn); font-size: 14px; line-height: 1.45; }
.nota b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--warn); margin-bottom: 4px; }
.origem { margin-top: 12px; font-size: 12px; color: var(--muted); }

/* ---------- botões ---------- */
.btn { display: block; width: 100%; padding: 15px; border-radius: 14px; font-weight: 600;
  font-size: 16px; background: var(--accent); color: #15181f; text-align: center; }
.btn.sec { background: var(--bg2); color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .4; }
.aval { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.aval button { padding: 14px 6px; border-radius: 14px; font-weight: 600; font-size: 14px; line-height: 1.2; }
.aval .e { background: var(--bad-bg); color: var(--bad); }
.aval .d { background: var(--warn-bg); color: var(--warn); }
.aval .a { background: var(--ok-bg); color: var(--ok); }
.aval span { display: block; font-size: 11px; font-weight: 500; opacity: .75; margin-top: 2px; }

/* ---------- listas ---------- */
.lista { display: grid; gap: 8px; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 13px 14px; border-radius: 12px; background: var(--bg2); width: 100%; text-align: left; }
.item .nome { font-weight: 600; font-size: 15px; }
.item .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item .n { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric { background: var(--bg2); border-radius: 12px; padding: 12px 8px; text-align: center; }
.metric .v { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.metric .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }

.caixas { display: grid; gap: 6px; }
.caixa { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 10px; font-size: 13px; }
.caixa .bar { height: 10px; background: var(--bg2); border-radius: 999px; overflow: hidden; }
.caixa .bar > div { height: 100%; background: var(--accent); border-radius: 999px; }
.caixa .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- tabs ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px); display: grid; grid-template-columns: repeat(3, 1fr);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line); z-index: 10; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; color: var(--muted); font-weight: 600; }
.tab .tab-ico { font-size: 17px; line-height: 1; }
.tab.on { color: var(--accent); }
