/* Speak Up — preto, verde e branco. Layout de app: topo fixo, conteúdo rolável,
   barra de navegação embaixo. */

:root {
  --bg: #05070a;
  --panel: #0c1014;
  --panel-2: #141b21;
  --line: #1f2a31;
  --line-soft: #172027;
  --txt: #ffffff;
  --muted: #8b9a93;
  --green: #1ee87a;
  --green-dim: #12a55a;
  --green-deep: #0a3d24;
  --green-soft: rgba(30, 232, 122, 0.12);
  --gold: #ffd233;
  --err: #ff6b6b;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: 'Rubik', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

h1, h2, h3, .display {
  font-family: 'Fredoka', 'Rubik', system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ------------------------------------------------------------------ topo -- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--panel);
  flex: none;
}
.logo { display: flex; align-items: center; gap: 8px; font-family: 'Fredoka', sans-serif; font-size: 17px; }
.logo i { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); display: block; }
.hud { display: flex; align-items: center; gap: 8px; }
.hud .chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.hud .chip.green { color: var(--green); border-color: rgba(30, 232, 122, 0.35); }

/* --------------------------------------------------------------- conteúdo -- */
main {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.screen { padding: 16px; max-width: 720px; margin: 0 auto; }
.screen.flush { padding: 0; }

.title { font-size: 20px; margin: 0 0 2px; }
.subtitle { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: grid; gap: 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

/* --------------------------------------------------------------- botões --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--panel-2); color: var(--txt);
  border: 1px solid var(--line); border-bottom-width: 3px;
  border-radius: 12px; padding: 12px 18px;
  font-weight: 500; font-family: 'Fredoka', sans-serif; font-size: 15px;
  transition: transform 0.08s ease;
}
.btn:active { transform: translateY(2px); border-bottom-width: 1px; }
.btn.primary {
  background: var(--green); color: #04130a;
  border-color: var(--green-dim); border-bottom-color: #0a6b39;
  font-weight: 600;
}
.btn.ghost { background: transparent; border-bottom-width: 1px; color: var(--muted); }
.btn.block { width: 100%; }
.btn.small { padding: 8px 13px; font-size: 13.5px; border-bottom-width: 2px; }
.btn:disabled { opacity: 0.4; }

select, input[type='text'], textarea {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; width: 100%;
}
select:focus, input:focus, textarea:focus, .btn:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--green); outline-offset: 2px;
}
textarea { resize: vertical; min-height: 90px; font-family: inherit; }
input[type='range'] { width: 100%; accent-color: var(--green); }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

/* ------------------------------------------------------- navegação baixo -- */
body.in-mission .nav { display: none; }

.nav {
  flex: none;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--panel); border-top: 1px solid var(--line-soft);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: grid; justify-items: center; gap: 2px;
  padding: 9px 4px 10px; color: var(--muted);
  font-size: 11px; font-weight: 500;
}
.tab span.ico { font-size: 20px; line-height: 1.1; filter: grayscale(1); opacity: 0.5; }
.tab[aria-selected='true'] { color: var(--green); box-shadow: inset 0 2px 0 var(--green); }
.tab[aria-selected='true'] span.ico { opacity: 1; }

/* ------------------------------------------------------------- mapa ------- */
.world-head {
  position: sticky; top: 0; z-index: 3;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  padding: 14px 16px 12px; text-align: center;
}
.world-head h2 { font-size: 17px; margin: 0; }
.world-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.world-head p:last-child { font-size: 11.5px; opacity: 0.75; margin-top: 4px; }

.map { max-width: 420px; margin: 0 auto; padding: 0 8px 40px; }
.map svg { width: 100%; height: auto; display: block; overflow: visible; }
.node-btn { cursor: pointer; }
.node-btn:focus-visible { outline: none; }
.node-btn:focus-visible .node-ring { stroke: #fff; stroke-width: 1.2; }
.pulse { animation: pulse 2s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.92); }
  50% { opacity: 0.08; transform: scale(1.18); }
}

.daily {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(120deg, var(--green-deep), var(--panel));
  border: 1px solid rgba(30, 232, 122, 0.35);
  border-radius: var(--radius); padding: 13px 15px;
  margin: 0 auto 4px; max-width: 420px;
}
.daily b { font-family: 'Fredoka', sans-serif; font-size: 15px; }
.daily p { margin: 0; font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------------ fase ------- */
.mission-top {
  display: grid; grid-template-columns: 40px 1fr 40px; align-items: center;
  gap: 8px; padding: 12px 16px 6px; max-width: 720px; margin: 0 auto;
}
.mission-top h2 { font-size: 16px; margin: 0; text-align: center; }
.mission-top .close { font-size: 22px; color: var(--muted); }
.dots { display: flex; gap: 5px; justify-content: center; padding: 8px 16px 14px; }
.dot { width: 26px; height: 5px; border-radius: 999px; background: var(--line); }
.dot.done { background: var(--green); }
.dot.now { background: var(--txt); }

.task {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 18px;
  max-width: 720px; margin: 0 auto;
}
.task .kind {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--green); font-weight: 500; margin-bottom: 10px;
}
.task .prompt {
  font-family: 'Fredoka', sans-serif; font-size: clamp(19px, 5vw, 24px);
  line-height: 1.35; margin: 0 0 12px;
}
.task .prompt.pt { font-size: clamp(17px, 4.4vw, 21px); }
.task .hint { font-size: 13.5px; color: var(--muted); }
details.model { margin-top: 10px; font-size: 13.5px; color: var(--muted); }
details.model summary { cursor: pointer; color: var(--green); }
details.model p { margin: 6px 0 0; font-style: italic; }

.live { min-height: 22px; color: var(--muted); font-style: italic; font-size: 14px; text-align: center; }
.mic {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--green); color: #04130a; font-size: 36px;
  display: grid; place-items: center; margin: 0 auto;
  box-shadow: 0 0 0 6px var(--green-soft);
  border: none;
}
.mic[data-state='listening'] { background: var(--err); color: #fff; box-shadow: 0 0 0 10px rgba(255, 107, 107, 0.18); }
.mic[data-state='processing'] { background: var(--gold); color: #2a2000; }
.mic:disabled { background: var(--panel-2); color: var(--muted); box-shadow: none; }

/* ----------------------------------------------------- correção / resposta */
.fix { border-radius: 12px; padding: 13px 15px; background: var(--panel-2); border: 1px solid var(--line); }
.fix.ok { border-color: rgba(30, 232, 122, 0.4); background: var(--green-soft); }
.fix .said { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.fix .diff { font-size: 17px; line-height: 1.45; font-family: 'Fredoka', sans-serif; }
.fix del { color: var(--err); text-decoration: line-through; text-decoration-thickness: 2px; }
.fix ins { color: var(--green); text-decoration: none; }
.notes { display: grid; gap: 6px; margin-top: 12px; }
.note {
  font-size: 13.5px; border-left: 2px solid var(--green-dim);
  padding: 2px 0 2px 10px; color: var(--muted);
}
.note b { color: var(--txt); font-weight: 500; }
.score-line { font-family: 'Fredoka', sans-serif; font-size: 15px; }

.word-ok { color: var(--green); }
.word-close { color: var(--gold); }
.word-miss { color: var(--err); text-decoration: underline; }
.word-extra { color: var(--muted); text-decoration: line-through; }

/* ---------------------------------------------------------- resultado ----- */
.result { text-align: center; padding: 30px 16px; max-width: 420px; margin: 0 auto; }
.result h2 { font-size: 26px; margin: 14px 0 4px; }
.stars-big { font-size: 46px; letter-spacing: 4px; }
.stars-big .on { color: var(--gold); }
.stars-big .off { color: var(--line); }
.result .gain { color: var(--green); font-family: 'Fredoka', sans-serif; font-size: 20px; margin: 6px 0 18px; }

/* --------------------------------------------------------------- chat ----- */
.chat { display: flex; flex-direction: column; gap: 14px; padding-bottom: 8px; }
.msg { max-width: 88%; display: grid; gap: 6px; }
.msg.tutor { justify-self: start; }
.msg.me { justify-self: end; justify-items: end; }
.bubble {
  padding: 11px 14px; border-radius: 16px; background: var(--panel-2);
  border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word;
}
.msg.me .bubble { background: var(--green-deep); border-color: rgba(30, 232, 122, 0.3); }
.msg .btn { justify-self: start; padding: 5px 12px; font-size: 13px; border-bottom-width: 2px; }
.bubble.system { background: transparent; border-style: dashed; color: var(--muted); font-size: 13px; }
.composer { display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line-soft); }

.partner { display: flex; align-items: center; gap: 10px; }
.partner .flag { font-size: 26px; }
.partner b { font-family: 'Fredoka', sans-serif; font-size: 15px; display: block; }
.partner p { margin: 0; font-size: 12px; color: var(--muted); }

.switch { display: flex; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.switch button { flex: 1; border-radius: 999px; padding: 8px 12px; color: var(--muted); font-weight: 500; font-size: 14px; }
.switch button[aria-pressed='true'] { background: var(--green); color: #04130a; font-weight: 600; }

/* -------------------------------------------------------------- números --- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; }
.tile b { display: block; font-family: 'Fredoka', sans-serif; font-size: 24px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; color: var(--muted); }
.bar { height: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--green); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list li { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; font-size: 14px; }
.wrong { color: var(--err); }
.right { color: var(--green); }

.banner {
  border: 1px solid rgba(255, 210, 51, 0.35); background: rgba(255, 210, 51, 0.07);
  border-radius: 12px; padding: 11px 13px; font-size: 13px; color: #ffe9a8;
}

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: var(--green); color: #04130a; font-weight: 600;
  padding: 10px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: all 0.22s ease; z-index: 40;
  font-family: 'Fredoka', sans-serif; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
