:root {
  --bg: #0e1215;
  --surface: #161c21;
  --surface-2: #1d252b;
  --line: #2a343c;
  --text: #e8eef1;
  --muted: #98a6ae;
  --faint: #6c7a83;
  --accent: #4cc9b0;
  --accent-ink: #04241e;
  --accent-soft: rgba(76, 201, 176, 0.14);
  --good: #6fd08c;
  --good-soft: rgba(111, 208, 140, 0.14);
  --warn: #f2b84b;
  --warn-soft: rgba(242, 184, 75, 0.14);
  --bad: #f07d6c;
  --bad-soft: rgba(240, 125, 108, 0.14);
  --radius: 16px;
  --nav-h: 66px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0.2em 0 0.4em; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 0 0 0.5em; }
h3 { font-size: 1rem; margin: 0 0 0.4em; color: var(--muted); font-weight: 600; text-transform: none; }
p { margin: 0.4em 0 0.8em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.88rem; }
.tiny { font-size: 0.78rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

#app { max-width: 560px; margin: 0 auto; padding: 14px 16px calc(var(--nav-h) + 28px + var(--safe-b)); }
body.focus #app { padding-bottom: calc(24px + var(--safe-b)); }

/* ---------- Topo ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; letter-spacing: 0.01em; }
.brand svg { width: 30px; height: 30px; }
.topbar .spacer { flex: 1; }

/* ---------- Navegação de baixo ---------- */
nav.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(14, 18, 21, 0.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
nav.bottom .inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); height: var(--nav-h); }
nav.bottom a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); text-decoration: none; font-size: 0.76rem; font-weight: 600;
}
nav.bottom a svg { width: 24px; height: 24px; }
nav.bottom a.on { color: var(--accent); }
body.focus nav.bottom { display: none; }

/* ---------- Cartões e blocos ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.card.flat { background: transparent; }
.card.accent { border-color: rgba(76, 201, 176, 0.45); background: linear-gradient(180deg, rgba(76, 201, 176, 0.10), var(--surface) 70%); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 10px 18px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-weight: 650; cursor: pointer; text-align: center; line-height: 1.2;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
}
a.btn { text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad-soft); border-color: rgba(240, 125, 108, 0.5); color: #ffd2cb; }
.btn.big { min-height: 64px; font-size: 1.1rem; border-radius: 18px; }
.btn.block { width: 100%; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 0.9rem; border-radius: 12px; }
.btn.icon { min-width: 52px; padding: 0 14px; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn .sub { display: block; font-size: 0.78rem; font-weight: 500; opacity: 0.8; }
.btn.col { flex-direction: column; gap: 2px; }
.linkbtn { background: none; border: 0; color: var(--accent); padding: 8px 4px; cursor: pointer; font-weight: 600; }
.linkbtn.muted { color: var(--muted); }

.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip {
  min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 650; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
}
.chip small { font-weight: 500; color: var(--muted); font-size: 0.72rem; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip.on small { color: var(--accent); }

/* ---------- Formulários ---------- */
label.field { display: block; margin: 12px 0; }
label.field > span { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
  width: 100%; min-height: 52px; padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input.answer { font-size: 1.2rem; min-height: 58px; }
.answer-row { display: flex; gap: 8px; }
.answer-row input { flex: 1; }

/* ---------- Semana ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 8px; }
.week .d { text-align: center; font-size: 0.72rem; color: var(--faint); }
.week .dot { width: 30px; height: 30px; margin: 4px auto 0; border-radius: 50%; border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; }
.week .dot.done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.week .dot.today { border-color: var(--accent); }
.week .dot svg { width: 16px; height: 16px; }

/* ---------- Números ---------- */
.stat { background: var(--surface-2); border-radius: 14px; padding: 12px; }
.stat .v { font-size: 1.5rem; font-weight: 750; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 0.8rem; color: var(--muted); }
.metric { padding: 14px 0; border-top: 1px solid var(--line); }
.metric:first-of-type { border-top: 0; padding-top: 4px; }
.metric .head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.metric .name { font-weight: 650; }
.metric .val { font-size: 1.35rem; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric .why { font-size: 0.86rem; color: var(--muted); margin: 4px 0 0; }
.bar { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; margin-top: 8px; position: relative; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 6px; }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }
.bar .goal { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: 0.7; }

/* ---------- Sessão ---------- */
.sess-head { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0 10px; margin: -14px 0 6px; }
.sess-head .row { flex-wrap: nowrap; }
.steps { display: flex; gap: 4px; flex: 1; }
.steps i { flex: 1; height: 6px; border-radius: 4px; background: var(--surface-2); }
.steps i.done { background: var(--accent); }
.steps i.now { background: linear-gradient(90deg, var(--accent) var(--p, 30%), var(--surface-2) var(--p, 30%)); }
.blocklabel { font-size: 0.82rem; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; }

.kicker { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); font-weight: 700; margin-bottom: 6px; }
.prompt-pt { color: var(--muted); font-size: 1rem; margin: 6px 0 12px; }
.sentence { font-size: 1.32rem; line-height: 1.45; margin: 8px 0 14px; }
.sentence .blank { display: inline-block; min-width: 3.2em; border-bottom: 2px solid var(--accent); color: var(--accent); text-align: center; }
.sentence mark, .hl { background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 0 4px; }
.bigword { font-size: 2rem; font-weight: 750; margin: 6px 0 2px; }
.result { border-radius: 14px; padding: 12px 14px; margin: 12px 0; }
.result.ok { background: var(--good-soft); border: 1px solid rgba(111, 208, 140, 0.4); }
.result.warn { background: var(--warn-soft); border: 1px solid rgba(242, 184, 75, 0.45); }
.result.bad { background: var(--bad-soft); border: 1px solid rgba(240, 125, 108, 0.45); }
.result b { display: block; margin-bottom: 2px; }
.grades { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.grades.four { grid-template-columns: repeat(4, 1fr); }
.grades .btn { flex-direction: column; gap: 2px; min-height: 60px; padding: 8px 4px; }
.grades .btn small { font-weight: 500; font-size: 0.74rem; opacity: 0.8; }
.grades .again { border-color: rgba(240, 125, 108, 0.5); }
.grades .good { border-color: rgba(76, 201, 176, 0.6); }

.heard { display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: 1.15rem; margin: 8px 0; }
.heard span { padding: 1px 6px; border-radius: 6px; }
.heard .ok { background: var(--good-soft); color: #bff0cc; }
.heard .miss { background: var(--bad-soft); color: #ffcdc5; text-decoration: underline dotted; }
.mic { width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; margin: 8px auto; cursor: pointer; }
.mic svg { width: 38px; height: 38px; }
.mic.live { animation: pulse 1.1s ease-in-out infinite; background: var(--bad); color: #2a0b06; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(240, 125, 108, 0.6); } 50% { box-shadow: 0 0 0 16px rgba(240, 125, 108, 0); } }
.timer { font-size: 2.4rem; font-weight: 750; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Leitura ---------- */
.reader { font-size: 1.22rem; line-height: 1.75; }
.reader .sent { display: inline; border-radius: 6px; transition: background 0.2s; }
.reader .sent.active { background: var(--accent-soft); }
.reader .w { cursor: pointer; border-radius: 4px; padding: 0 1px; }
.reader .w.tapped { background: var(--warn-soft); box-shadow: inset 0 -2px 0 var(--warn); }
.reader .w.learning { box-shadow: inset 0 -2px 0 rgba(76, 201, 176, 0.6); }
.reader .tr { display: block; color: var(--muted); font-size: 0.95rem; line-height: 1.45; margin: 2px 0 10px; }
.tag { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.pre { display: flex; flex-wrap: wrap; gap: 6px; }
.pre span { background: var(--surface-2); border-radius: 10px; padding: 4px 10px; font-size: 0.92rem; }
.pre span b { color: var(--accent); }

/* ---------- Painel inferior (significado da palavra) ---------- */
.sheet-wrap { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: var(--surface); border-top-left-radius: 22px; border-top-right-radius: 22px; padding: 18px 18px calc(18px + var(--safe-b)); border: 1px solid var(--line); animation: up 0.18s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px auto 12px; }

/* ---------- Diálogos e avisos ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px; max-width: 420px; width: 100%; }
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 14px + var(--safe-b)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 14px; }
body.focus #toasts { bottom: calc(18px + var(--safe-b)); }
.toast { background: #253038; border: 1px solid var(--line); color: var(--text); padding: 12px 16px; border-radius: 14px; max-width: 520px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4); transition: opacity 0.4s, transform 0.4s; }
.toast.warn { border-color: rgba(242, 184, 75, 0.6); }
.toast.bad { border-color: rgba(240, 125, 108, 0.6); }
.toast.out { opacity: 0; transform: translateY(8px); }
.banner { border-radius: 14px; padding: 12px 14px; margin: 10px 0; background: var(--warn-soft); border: 1px solid rgba(242, 184, 75, 0.45); font-size: 0.92rem; }
.banner.info { background: var(--accent-soft); border-color: rgba(76, 201, 176, 0.4); }

/* ---------- Gráficos ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .grid { stroke: var(--line); stroke-width: 1; fill: none; }
.chart .axis-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.chart .area { fill: rgba(76, 201, 176, 0.22); stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .pending { fill: none; stroke: var(--faint); stroke-dasharray: 3 4; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 12px 0; border-top: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.list li:first-child { border-top: 0; }
.list li .grow { flex: 1; min-width: 0; }

.option-list { display: grid; gap: 8px; margin-top: 10px; }
.option-list .btn { justify-content: flex-start; text-align: left; font-weight: 600; }
.option-list .btn.picked { border-color: var(--accent); background: var(--accent-soft); }
.yn { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.yn .btn { min-height: 72px; font-size: 1.1rem; }
.testword { font-size: 2.2rem; font-weight: 750; text-align: center; margin: 26px 0 8px; letter-spacing: 0.01em; }

@media (min-width: 600px) { #app { padding-top: 24px; } }
