:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1c2421;
  --muted: #66706b;
  --line: #e3dfd6;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #d9efec;
  --accent: #e0662f;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --miss: #b42318;
  --miss-soft: #fde4e1;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615;
    --surface: #1c2220;
    --ink: #eef2f0;
    --muted: #9aa5a0;
    --line: #2c3431;
    --brand: #2dd4bf;
    --brand-ink: #062b27;
    --brand-soft: #123a36;
    --ok: #4ade80;
    --ok-soft: #12321f;
    --miss: #f87171;
    --miss-soft: #3a1717;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; }
button, input, select, textarea { font: inherit; color: inherit; }

.screen {
  display: none;
  max-width: 640px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}
.screen.active { display: block; }

.top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin: 4px 0 16px;
}
#home .top { grid-template-columns: 1fr auto; }
.top h2 { text-align: center; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .75rem; }
.center { display: grid; justify-items: center; gap: 10px; margin: 20px 0; }
.section-title { font-size: .95rem; margin: 24px 0 10px; color: var(--muted); font-weight: 600; }
.step { margin: 18px 0 8px; }

/* Botões */
.btn {
  border: 0;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}
.btn.small { padding: 8px 14px; font-size: .9rem; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.outline { background: transparent; color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }
.btn.ghost { background: var(--brand-soft); color: var(--ink); }
.btn.rec { background: var(--accent); color: #fff; }
.btn:active, .card:active, .row:active { transform: scale(.98); }
.icon-btn {
  border: 0;
  background: transparent;
  font-size: 1.25rem;
  min-width: 40px;
  min-height: 40px;
  border-radius: 12px;
  cursor: pointer;
}
.icon-btn.small { font-size: 1rem; min-width: 32px; min-height: 32px; }
.icon-btn:hover { background: var(--brand-soft); }

/* Início */
.banner {
  background: var(--brand-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.stats {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}
.stat span { font-size: 1.5rem; font-weight: 700; color: var(--brand); }
.stat small { color: var(--muted); font-size: .75rem; }
.stat.goal { justify-items: stretch; }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.bar div { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .4s; }

.cards { display: grid; gap: 10px; }
.card {
  text-align: left;
  border: 0;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
  cursor: pointer;
}
.card b { font-size: 1.05rem; }
.card span { color: var(--muted); font-size: .9rem; }
.card.primary { background: var(--brand); color: var(--brand-ink); padding: 22px 18px; }
.card.primary span { color: inherit; opacity: .85; }

/* Listas */
.list { display: grid; gap: 8px; }
.row {
  text-align: left;
  border: 0;
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
  cursor: pointer;
}
.phrase {
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  align-items: start;
}
.phrase > .phrase-actions { grid-column: 1 / -1; }
.phrase-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.shadow-box { flex-basis: 100%; font-size: .95rem; }
.shadow-box:empty { display: none; }
.diff { font-size: 1.05rem; margin: 4px 0; }
.diff .ok { color: var(--ok); font-weight: 600; }
.diff .miss { color: var(--miss); text-decoration: underline wavy; font-weight: 600; }
.rec-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); animation: pulse 1s infinite; vertical-align: middle;
}

/* Conversa */
.chat-screen.active { display: flex; flex-direction: column; height: 100dvh; padding-bottom: 0; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chip {
  flex: none;
  font-size: .8rem;
  padding: 6px 10px;
  border-radius: 99px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  white-space: nowrap;
}
.chip.used { background: var(--ok-soft); color: var(--ok); box-shadow: none; font-weight: 600; }
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 0 12px; }
.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.bubble.ai { background: var(--surface); align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble.me { background: var(--brand); color: var(--brand-ink); align-self: flex-end; border-bottom-right-radius: 6px; }
.bubble.pending { opacity: .6; }
.bubble.failed { background: var(--miss-soft); color: var(--miss); }
.bubble-tools { display: flex; gap: 2px; margin: 4px -6px -4px; }
.bubble .pt { margin-top: 4px; }
.feedback {
  align-self: flex-end;
  max-width: 92%;
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: .95rem;
  border-left: 4px solid var(--accent);
  display: grid;
  gap: 4px;
}
.feedback .good { color: var(--ok); font-weight: 600; }
.tag {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
  background: var(--accent); color: #fff; padding: 2px 6px; border-radius: 6px; vertical-align: middle;
}
.pron { font-size: .9rem; }
.pron ul { margin: 4px 0 0; padding-left: 18px; }
.thinking { padding: 12px 16px; }
.dots i {
  display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%;
  background: var(--muted); animation: blink 1.2s infinite;
}
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }

.composer {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 6px;
  align-items: center;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.composer input {
  min-width: 0;
  padding: 12px 14px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.mic {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(224,102,47,.35);
}
.mic.big { width: 96px; height: 96px; font-size: 2.4rem; }
.mic[data-state=rec] { background: var(--miss); animation: pulse 1.2s infinite; }

.howto {
  position: relative;
  background: var(--brand-soft);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: grid;
  gap: 4px;
}
.howto .close { position: absolute; top: 4px; right: 4px; }
.big-en { font-size: 1.25rem; font-weight: 700; }
.big-pt { font-size: 1.2rem; font-weight: 600; margin: 6px 0 10px; }

/* Caderno */
.review {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
}
.review.done { color: var(--ok); font-weight: 600; }
.answer { display: grid; gap: 8px; }
.row-btns { display: flex; gap: 8px; }

/* Formulário */
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
.form input, .form select, .form textarea {
  font-weight: 400;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  width: 100%;
}
.form input[type=range] { padding: 0; }
.form p { margin: -6px 0 0; }

/* Diário e desafio */
.prompt-q { font-size: 1.3rem; font-weight: 700; text-align: center; margin: 18px 0 0; }
.typed { margin: 10px 0; }
.typed textarea { width: 100%; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); margin: 8px 0; }
.result-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-top: 12px;
  display: grid;
  gap: 8px;
}
.mistake { border-left: 3px solid var(--accent); padding-left: 10px; }
.mistake s { color: var(--miss); }
.mistake b { color: var(--ok); }
.situation { font-size: 1.35rem; font-weight: 700; text-align: center; margin: 24px 0 8px; }
.countdown { font-size: 3rem; font-weight: 800; color: var(--accent); text-align: center; font-variant-numeric: tabular-nums; }
.verdict-ok { color: var(--ok); font-weight: 700; }
.verdict-no { color: var(--miss); font-weight: 700; }

/* Live */
.orb {
  width: 140px; height: 140px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--brand-soft), var(--brand));
  transition: transform .2s;
}
.orb[data-state=listening] { animation: pulse 1.6s infinite; }
.orb[data-state=speaking] { transform: scale(1.12); background: radial-gradient(circle at 35% 35%, #ffd2bd, var(--accent)); }
.small-chat { max-height: 40dvh; font-size: .95rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 12px;
  max-width: 90vw;
  opacity: 0;
  pointer-events: none;
  transition: .25s;
  z-index: 10;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
