/* =========================================================
   MOBILE FIRST
   A base abaixo é para celular. As telas maiores recebem
   ajustes nos blocos @media (min-width: ...) no final.
   ========================================================= */

:root {
  --bg: #EAF0F7;
  --paper: #FFFFFF;
  --ink: #16213A;
  --muted: #56627C;
  --line: #D3DCE8;
  --cobalt: #2446D8;
  --cobalt-soft: #E1E8FF;
  --marker: #FFD84A;
  --ok: #13815A;
  --ok-soft: #DCF2E8;
  --bad: #C4344A;
  --bad-soft: #FBE2E6;
  --display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius-lg: 20px;
  --radius-sm: 12px;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1527;
    --paper: #17213A;
    --ink: #E9EFFA;
    --muted: #9DAAC6;
    --line: #2A375A;
    --cobalt: #86A0FF;
    --cobalt-soft: #223063;
    --marker: rgba(255, 216, 74, 0.32);
    --ok: #4CD39C;
    --ok-soft: #173A31;
    --bad: #FF7D91;
    --bad-soft: #43202A;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  /* ao rolar até um elemento, ele não fica escondido atrás da barra de abas */
  scroll-padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible, label:focus-within {
  outline: 3px solid var(--cobalt);
  outline-offset: 2px;
}

.app {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  /* espaço embaixo para a barra de abas fixa */
  padding: calc(16px + var(--safe-top)) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}

/* ---------- Cabeçalho ---------- */
.top { display: grid; gap: 14px; margin-bottom: 18px; }
.brand h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.8rem, 8.5vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin: 0 0 6px;
}
.brand p { display: none; margin: 0; color: var(--muted); font-size: 0.95rem; }
.brand-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  display: grid;
  place-items: center;
  color: var(--ink);
}
.icon-btn svg, .search-bar svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
}
.streak { font-size: 0.9rem; font-weight: 700; color: var(--muted); }
.streak.is-on { color: var(--ink); }

/* ---------- Aviso de revisão ---------- */
.review-banner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.review-banner p { margin: 0; }
.review-banner .btn { background: var(--marker); color: #16213A; border-color: var(--marker); }
body.is-review .tracks,
body.is-review .days,
body.is-review .day-head,
body.is-review .review-banner { display: none; }

.overall p { margin: 0 0 6px; color: var(--muted); font-size: 0.95rem; }
.overall strong { color: var(--ink); font-size: 1.2rem; }
.bar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ok);
  border-radius: inherit;
  transition: width 0.4s ease;
}

/* ---------- Trilhas: palavras ou phrasal verbs ---------- */
.tracks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 2px solid var(--line);
  margin-bottom: 14px;
}
.tracks button {
  border: 0;
  background: none;
  min-height: 52px;
  padding: 8px 6px 10px;
  margin-bottom: -2px;
  border-bottom: 3px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  color: var(--muted);
}
.tracks { grid-template-columns: repeat(4, 1fr); }
.tracks .t-name { font-family: var(--display); font-weight: 800; font-size: 0.92rem; line-height: 1.15; text-align: center; }
.tracks .t-count { font-size: 0.8rem; }
.tracks button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--cobalt); }
.tracks button[aria-selected="true"] .t-count { color: var(--cobalt); font-weight: 700; }

/* ---------- Faixa de dias (rolagem lateral no celular) ---------- */
.days {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 68px;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  /* vai de ponta a ponta da tela no celular */
  margin: 0 -16px;
  padding: 4px 16px 10px;
  scroll-padding-inline: 16px;
}
.days::-webkit-scrollbar { display: none; }

.day-tile {
  scroll-snap-align: start;
  position: relative;
  min-height: 76px;
  border: 2px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 8px 8px 10px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.day-tile .n { font-family: var(--display); font-weight: 800; font-size: 1.5rem; line-height: 1; }
.day-tile .d { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.day-tile .mini { height: 4px; background: var(--line); border-radius: 99px; margin-top: auto; overflow: hidden; }
.day-tile .mini span { display: block; height: 100%; background: var(--ok); }
.day-tile.is-today { border-color: var(--cobalt); }
.day-tile.is-today .d { color: var(--cobalt); font-weight: 700; }
.day-tile.is-active { background: var(--cobalt); border-color: var(--cobalt); color: var(--paper); }
.day-tile.is-active .d { color: inherit; opacity: 0.85; }
.day-tile.is-active .mini { background: rgba(255, 255, 255, 0.3); }
.day-tile.is-active .mini span { background: var(--paper); }
.day-tile .check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  font-size: 11px;
  display: grid;
  place-items: center;
}

/* ---------- Cabeçalho do dia ---------- */
.day-head { margin: 14px 0 16px; }
.day-head h2 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.8rem;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
}
.day-head p { margin: 4px 0 0; color: var(--muted); font-size: 0.95rem; }
.day-head .day-theme { color: var(--ink); font-weight: 700; font-size: 1.05rem; margin-top: 2px; }

/* ---------- Abas: barra fixa embaixo no celular (fácil de alcançar com o polegar) ---------- */
.modes {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + var(--safe-bottom));
}
.modes button {
  border: 0;
  background: none;
  min-height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}
.modes svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.modes button[aria-selected="true"] { color: var(--cobalt); background: var(--cobalt-soft); }
.modes button { position: relative; }
.badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 6px);
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--bad);
  color: #fff;
  font-size: 0.72rem;
  line-height: 20px;
  text-align: center;
}

/* ---------- Lista ---------- */
.note {
  background: var(--cobalt-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.95rem;
}
.note p { margin: 0; }
.note p + p { margin-top: 6px; }
.note [lang="en"] { font-weight: 700; }

.list-tools { margin-bottom: 8px; color: var(--muted); }
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  border-radius: 8px;
  font-size: 0.95rem;
}
.toggle input { width: 22px; height: 22px; flex: none; accent-color: var(--cobalt); }

.wordlist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.word {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 2px 12px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.word .en {
  display: block;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.45rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.word .pt { display: block; font-weight: 700; color: var(--cobalt); }
/* ---------- Ler ---------- */
.read-busy { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--cobalt-soft); font-weight: 700; }
.read-actions { display: grid; gap: 12px; }
.read-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.read-card h3, .read-list-title { font-family: var(--display); margin: 0 0 6px; }
.read-list-title { margin-top: 22px; }
.file-btn { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.book-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.book { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.book-open { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 12px 0; display: grid; gap: 2px; color: var(--ink); }
.book-title { font-family: var(--display); font-weight: 800; font-size: 1.1rem; overflow-wrap: anywhere; }
.book-tag { font-size: 0.75rem; font-weight: 700; color: var(--cobalt); }
.read-head h3 { font-family: var(--display); font-size: 1.3rem; margin: 4px 0; }
.book-stage { perspective: 1800px; margin: 4px 0; }
.book-sheet { transform-origin: left center; }
/* texto (txt e IA): página com cara de folha de livro */
.text-page {
  background: #FFFDF7; color: #1F2433;
  border: 1px solid var(--line); border-radius: 4px 12px 12px 4px;
  box-shadow: inset 6px 0 10px -6px rgba(0, 0, 0, 0.25), 0 6px 18px rgba(14, 21, 39, 0.12);
  padding: 22px 20px; font-family: Georgia, "Times New Roman", serif; font-size: 1.15rem; line-height: 1.75;
}
.text-page p { margin: 0 0 1em; }
.text-page p:last-child { margin-bottom: 0; }
.text-page .w { cursor: pointer; border-radius: 4px; }
.text-page .w.is-picked { background: var(--marker); color: #16213A; }
/* PDF: página desenhada como o original + texto invisível por cima */
.is-pdf .book-sheet { display: flex; justify-content: center; gap: 12px; }
.pdf-page {
  position: relative; flex: none; background: #fff;
  box-shadow: 0 6px 18px rgba(14, 21, 39, 0.18);
  --scale-round-x: 1px; --scale-round-y: 1px;
}
.pdf-page canvas { display: block; }
.textLayer {
  position: absolute; inset: 0; overflow: clip; text-align: initial; line-height: 1; opacity: 1;
  transform-origin: 0 0; z-index: 0; forced-color-adjust: none; caret-color: transparent;
  --min-font-size: 1;
  --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
  --min-font-size-inv: calc(1 / var(--min-font-size));
}
.textLayer span, .textLayer br {
  color: transparent; position: absolute; white-space: pre; cursor: pointer;
  transform-origin: 0% 0%; user-select: text; -webkit-user-select: text;
}
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) {
  z-index: 1; --font-height: 0; font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1; --rotate: 0deg;
  transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}
.textLayer .markedContent { display: contents; }
.textLayer ::selection { background: rgba(36, 70, 216, 0.3); color: transparent; }
/* EPUB: o epub.js desenha o livro dentro desta área */
.is-epub .book-sheet {
  height: min(72vh, 900px); background: #fff; border: 1px solid var(--line); border-radius: 4px 12px 12px 4px;
  box-shadow: inset 6px 0 10px -6px rgba(0, 0, 0, 0.25), 0 6px 18px rgba(14, 21, 39, 0.12);
  padding: 12px 10px; overflow: hidden;
}
/* folha virando: sai girando pela lombada e a próxima entra pelo outro lado */
.turn-out-next { animation: turnOutNext 0.24s ease-in forwards; transform-origin: left center; }
.turn-in-next { animation: turnInNext 0.24s ease-out; transform-origin: right center; }
.turn-out-prev { animation: turnOutPrev 0.24s ease-in forwards; transform-origin: right center; }
.turn-in-prev { animation: turnInPrev 0.24s ease-out; transform-origin: left center; }
@keyframes turnOutNext { to { transform: rotateY(-90deg); filter: brightness(0.75); } }
@keyframes turnInNext { from { transform: rotateY(90deg); filter: brightness(0.75); } }
@keyframes turnOutPrev { to { transform: rotateY(90deg); filter: brightness(0.75); } }
@keyframes turnInPrev { from { transform: rotateY(-90deg); filter: brightness(0.75); } }
.read-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0; }
.read-nav .btn { min-height: 44px; padding: 6px 16px; }
.read-count { color: var(--muted); font-weight: 700; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  max-height: 70vh; overflow-y: auto;
  background: var(--paper); border-top: 1px solid var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -8px 30px rgba(14, 21, 39, 0.18);
  padding: 14px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
}
.sheet[hidden] { display: none; }
.sheet-close { float: right; }
.sheet-word { display: flex; align-items: center; gap: 8px; }
.sheet-en { font-family: var(--display); font-weight: 800; font-size: 1.6rem; margin: 0; }
.sheet-pt { font-weight: 700; color: var(--cobalt); font-size: 1.15rem; margin: 6px 0 10px; }
.sheet-sentence { border-top: 1px solid var(--line); padding-top: 8px; margin-bottom: 10px; }
.sheet-sentence p { margin: 2px 0; }
.sheet-sel { font-size: 1.1rem; margin: 0; }
.sheet .speak { display: inline-grid; vertical-align: middle; }
.speak.slow { font-size: 1.1rem; line-height: 1; }

/* ---------- Falar ---------- */
.voice { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 16px 0; }
.mic-btn {
  width: 112px; height: 112px; border-radius: 50%;
  border: 0; background: var(--cobalt); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(36, 70, 216, 0.3);
}
.mic-btn svg { width: 48px; height: 48px; }
.mic-btn.is-on { background: var(--bad); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.voice-hint { color: var(--muted); margin: 0; }
.voice-msg { margin: 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--bad-soft); font-weight: 700; }
.voice-heard { margin: 0; color: var(--muted); }
.voice .prompt-row { justify-content: center; }
.next-row .btn svg { width: 20px; height: 20px; vertical-align: -4px; margin-right: 4px; }
.extra-tag { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 1px 8px; margin-bottom: 2px; border-radius: 99px; background: var(--marker); color: #16213A; }
.word .ex { grid-column: 2; margin: 4px 0 0; font-size: 0.95rem; }
.word .ex > span { display: block; }
.word .ex .ex-pt { color: var(--muted); }
.word .knew { grid-column: 2; justify-self: start; order: 1; } /* no celular fica depois do exemplo */
.is-sentences .word .en { font-size: 1.25rem; }
.ex-label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--muted); margin-top: 2px; }
.uses { margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.uses-label { font-size: 0.8rem; color: var(--muted); margin-right: 2px; }
.uchip {
  font-size: 0.8rem;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.uchip.pv { border-color: var(--cobalt); color: var(--cobalt); font-weight: 700; }
.word.flash { animation: flash 1.8s ease; }
@keyframes flash { 0%, 40% { background: var(--cobalt-soft); } 100% { background: transparent; } }
.word.is-known .en { text-decoration: underline 3px var(--ok); text-underline-offset: 5px; }

.list-hint { margin: 2px 0 6px; font-size: 0.95rem; color: var(--muted); }
.list-hint.small { font-size: 0.85rem; }
.list-hint b { color: var(--ok); }

/* tradução escondida: fica borrada até tocar */
.hide-pt [data-reveal] { cursor: pointer; border-radius: 8px; }
.hide-pt .word .pt,
.hide-pt .word .ex-pt { filter: blur(7px); user-select: none; transition: filter 0.2s; }
.hide-pt .word.reveal .pt,
.hide-pt .word.reveal .ex-pt { filter: none; user-select: auto; }

.knew {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: 0.95rem;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  border-radius: 8px;
}
.knew input { width: 22px; height: 22px; accent-color: var(--ok); }

.speak {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  display: grid;
  place-items: center;
  flex: none;
  color: var(--cobalt);
}
.speak svg { width: 20px; height: 20px; }
.speak:active { background: var(--cobalt-soft); }

/* ---------- Flashcards ---------- */
.stage { display: flex; flex-direction: column; align-items: stretch; gap: 16px; }
.stage-info { color: var(--muted); margin: 0; text-align: center; font-size: 0.95rem; }

.card-wrap {
  width: 100%;
  perspective: 1400px;
  touch-action: pan-y; /* deixa rolar a página na vertical, o arraste lateral é nosso */
  transition: transform 0.25s ease;
}
.card-wrap.dragging { transition: none; }
.card-wrap.swipe-right .face { border-color: var(--ok); box-shadow: 6px 6px 0 var(--ok); }
.card-wrap.swipe-left .face { border-color: var(--bad); box-shadow: 6px 6px 0 var(--bad); }

.card {
  position: relative;
  display: block;
  width: 100%;
  min-height: min(46vh, 360px);
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(.2, .8, .2, 1);
  border: 0;
  background: none;
  padding: 0;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
}
.card.flipped { transform: rotateY(180deg); }
.face {
  position: absolute;
  inset: 0 6px 6px 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: 6px 6px 0 var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 18px 44px;
  gap: 10px;
}
.face.back { transform: rotateY(180deg); }
.face .hint { position: absolute; left: 12px; right: 12px; bottom: 14px; font-size: 0.85rem; color: var(--muted); }

.big-word {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.6rem, 15vw, 5rem);
  line-height: 1;
  letter-spacing: -0.03em;
  overflow-wrap: break-word;
  max-width: 100%;
}
/* marca-texto: acompanha cada linha quando a expressão quebra */
.big-word .hl {
  padding: 0 0.12em;
  background: linear-gradient(transparent 58%, var(--marker) 58%, var(--marker) 92%, transparent 92%);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.big-word.sentence { font-size: clamp(1.6rem, 7.5vw, 2.6rem); line-height: 1.2; letter-spacing: -0.01em; }
.back .pt-big.sentence { font-size: clamp(1.3rem, 6vw, 2rem); }
.card-tag {
  position: absolute;
  top: 14px;
  left: 16px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cobalt);
}
/* phrasal verbs longos, como "look forward to" */
.big-word.long { font-size: clamp(2.1rem, 11vw, 3.8rem); line-height: 1.1; }
.back .pt-big {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(1.7rem, 8vw, 2.6rem);
  line-height: 1.1;
  color: var(--cobalt);
}
.back .en-small { font-weight: 700; color: var(--muted); }
.back .ex { margin: 6px 0 0; max-width: 34ch; }
.back .ex span { display: block; }
.back .ex .ex-pt { color: var(--muted); font-size: 0.95rem; }

/* botões de resposta: ocupam a largura toda no celular */
.answer-row { display: flex; gap: 10px; align-items: center; }
.answer-row .btn { flex: 1; white-space: nowrap; padding: 10px 12px; }

.btn {
  border: 2px solid var(--ink);
  background: var(--paper);
  border-radius: 99px;
  padding: 10px 18px;
  font-weight: 700;
  min-height: 52px;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.good { border-color: var(--ok); background: var(--ok-soft); color: var(--ink); }
.btn.again { border-color: var(--bad); background: var(--bad-soft); color: var(--ink); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.link-btn {
  border: 0;
  background: none;
  color: var(--muted);
  text-decoration: underline;
  min-height: 44px;
  padding: 6px 8px;
  border-radius: 8px;
  align-self: center;
}

/* ajuda de teclado só aparece em computador */
.kbd-help { display: none; font-size: 0.85rem; color: var(--muted); text-align: center; margin: 0; }
kbd {
  font-family: var(--body);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 5px;
  background: var(--paper);
}
.touch-only { display: inline; }

/* ---------- Quiz ---------- */
.quiz-types {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px 16px;
  padding: 2px 16px;
}
.quiz-types::-webkit-scrollbar { display: none; }
.quiz-types .chip { flex: none; white-space: nowrap; }
.chip {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-height: 44px;
  font-size: 0.9rem;
  line-height: 1.2;
}
.chip[aria-pressed="true"] { border-color: var(--cobalt); background: var(--cobalt-soft); font-weight: 700; }

.q-progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 18px; }
.q-progress span { display: block; height: 100%; background: var(--cobalt); transition: width 0.3s; }

.question { margin-bottom: 16px; }
.question .ask { color: var(--muted); margin: 0 0 4px; font-size: 0.95rem; }
.question .prompt-row { display: flex; align-items: center; gap: 12px; }
.question .prompt.sentence { font-size: clamp(1.5rem, 7vw, 2.4rem); line-height: 1.2; }
.listen-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 2px solid var(--cobalt);
  background: var(--cobalt-soft);
  color: var(--cobalt);
  border-radius: 99px;
  padding: 12px 22px 12px 16px;
  font-weight: 700;
  min-height: 60px;
}
.listen-btn svg { width: 32px; height: 32px; }
.write-form { display: flex; flex-direction: column; gap: 10px; }
.write-form input {
  width: 100%;
  font: inherit;
  font-size: 1.15rem;
  padding: 14px 16px;
  min-height: 56px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
}
.write-form input:focus { outline: none; border-color: var(--cobalt); }
.write-form input:disabled { opacity: 0.8; }
.build-line {
  min-height: 64px;
  padding: 10px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.build-line.is-ok { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }
.build-line.is-wrong { border-style: solid; border-color: var(--bad); background: var(--bad-soft); }
.build-empty { color: var(--muted); font-size: 0.95rem; }
.build-pool { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tok {
  border: 2px solid var(--ink);
  background: var(--paper);
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 44px;
  font-weight: 700;
  font-size: 1.05rem;
}
.tok.ghost { border-style: dashed; border-color: var(--line); color: transparent; }
.tok:disabled { cursor: default; }
.build-actions { display: flex; gap: 10px; }
.build-actions .btn { flex: 1; }
.question .prompt {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2rem, 11vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0;
  overflow-wrap: anywhere;
}

.options { display: grid; grid-template-columns: 1fr; gap: 10px; }
.option {
  text-align: left;
  border: 2px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-weight: 700;
  min-height: 56px;
}
.option:disabled { cursor: default; }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }

.feedback {
  margin-top: 16px;
  padding: 14px 16px;
  border-left: 4px solid var(--ok);
  background: var(--paper);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.feedback.is-wrong { border-left-color: var(--bad); }
.feedback p { margin: 0; }
.feedback .ex-pt { color: var(--muted); }
.next-row { margin-top: 14px; display: flex; }
.next-row .btn { flex: 1; }

/* ---------- Resultado ---------- */
.result { text-align: center; padding: 16px 0; }
.result .score {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(3.6rem, 22vw, 6.5rem);
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 0;
  color: var(--ink);
}
.result .score small { font-size: 0.4em; color: var(--muted); letter-spacing: 0; }
.result h3 { font-family: var(--display); font-size: 1.4rem; margin: 10px 0 6px; }
.result > p:not(.score) { color: var(--muted); margin: 0 auto 18px; max-width: 42ch; }
.result .answer-row { flex-direction: column; align-items: stretch; margin-top: 8px; }
.missed-list { list-style: none; padding: 0; margin: 0 auto 18px; text-align: left; }
.missed-list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; }
.missed-list b { font-family: var(--display); }
.missed-list span { text-align: right; color: var(--muted); }

/* ---------- Rodapé ---------- */
.foot {
  margin-top: 40px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--muted);
}
.foot p { margin: 0; }
.foot .link-btn { align-self: flex-start; padding-left: 0; }
.foot-actions { display: flex; flex-direction: column; align-items: flex-start; }
.ios-hint { font-size: 0.85rem; }
.sync-info { font-size: 0.9rem; }
.sync-code { font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.04em; color: var(--ink); }
.sync-hint { display: block; font-size: 0.85rem; }

/* ---------- Busca ---------- */
.search {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}
.search[hidden] { display: none; }
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
}
.search-bar input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.05rem;
  border: 0;
  background: none;
  color: var(--ink);
  min-height: 44px;
}
.search-bar input:focus { outline: none; }
.search-results {
  list-style: none;
  margin: 0;
  padding: 0 0 calc(24px + var(--safe-bottom));
  overflow-y: auto;
  flex: 1;
}
.search-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  padding: 12px 16px;
  display: grid;
  gap: 2px;
}
.s-en { font-family: var(--display); font-weight: 800; font-size: 1.15rem; }
.s-pt { color: var(--cobalt); font-weight: 700; }
.s-meta { font-size: 0.85rem; color: var(--muted); }
.search-empty { padding: 16px; color: var(--muted); }
body.no-scroll { overflow: hidden; }

/* ---------- Minhas frases ---------- */
.mine-title { flex: 1; margin: 0; font-family: var(--display); font-size: 1.2rem; color: var(--ink); }
.mine-body { flex: 1; overflow-y: auto; padding: 16px 16px calc(24px + var(--safe-bottom)); background: var(--bg); }
.mine-form { display: grid; gap: 12px; }
.mine-form label { display: grid; gap: 4px; font-weight: 700; font-size: 0.95rem; }
.mine-form small { font-weight: 400; color: var(--muted); }
.mine-form input {
  width: 100%;
  font: inherit;
  font-weight: 400;
  padding: 10px 14px;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
}
.mine-form input:focus { outline: none; border-color: var(--cobalt); }
.mine-count { color: var(--muted); margin: 18px 0 8px; }
.mine-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.mine-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.mine-item > div { flex: 1; min-width: 0; display: grid; gap: 2px; overflow-wrap: anywhere; }
.mine-item .link-btn { color: var(--bad); min-height: 44px; }
body.is-empty .days,
body.is-empty .day-head,
body.is-empty .modes { display: none; }
.note .answer-row { margin-top: 10px; }
.ai-btn { width: 100%; }
.mine-or { color: var(--muted); margin: 18px 0 8px; }
.remove-word { grid-column: 2; justify-self: start; color: var(--bad); font-size: 0.9rem; min-height: 36px; padding: 4px 0; }
.link-btn.inline { padding: 0; min-height: 0; color: var(--cobalt); font-weight: 700; text-decoration: underline; }

/* ---------- Aviso rápido ---------- */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  z-index: 60;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 700;
  text-align: center;
}
.toast[hidden] { display: none; }

/* =========================================================
   TELAS MAIORES
   ========================================================= */

/* Celular grande / deitado */
@media (min-width: 480px) {
  .brand p { display: block; }
  .options { grid-template-columns: 1fr 1fr; }
  .result .answer-row { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .result .answer-row .btn { flex: 0 1 auto; }
  .missed-list { max-width: 440px; }
}

/* Tablet */
@media (min-width: 720px) {
  html { scroll-padding-bottom: 16px; }
  body { font-size: 17px; }
  .app { padding: calc(32px + var(--safe-top)) 28px calc(48px + var(--safe-bottom)); }

  .tracks { display: inline-grid; grid-template-columns: repeat(4, auto); gap: 8px; }
  .tracks .t-name { font-size: 1.1rem; }
  .review-banner { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; }
  .review-banner .btn { flex: none; }
  .quiz-types { margin: 0 0 18px; padding: 2px 0; flex-wrap: wrap; }
  .write-form { flex-direction: row; }
  .write-form .btn { flex: none; min-width: 140px; }
  .build-actions .btn { flex: 0 1 auto; min-width: 140px; }
  .foot-actions { flex-direction: row; flex-wrap: wrap; gap: 0 16px; }
  .toast { left: 50%; right: auto; transform: translateX(-50%); bottom: 24px; max-width: 480px; }
  .search { inset: 0; background: rgba(14, 21, 39, 0.4); padding: 8vh 16px; align-items: center; }
  .search-bar, .search-results { width: 100%; max-width: 640px; }
  .search-bar { border-radius: var(--radius-sm) var(--radius-sm) 0 0; border: 1px solid var(--line); }
  .mine-body { flex: 0 1 auto; width: 100%; max-width: 640px; max-height: 76vh; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
  .search-results { flex: 0 1 auto; max-height: 70vh; background: var(--bg); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm); padding-bottom: 0; }
  .tracks button { flex-direction: row; align-items: baseline; gap: 8px; padding: 8px 14px 10px; }
  .top { grid-template-columns: 1fr 260px; align-items: end; gap: 16px 32px; margin-bottom: 28px; }

  .days { margin: 0 -28px; padding: 4px 28px 10px; scroll-padding-inline: 28px; }

  /* abas voltam para o topo, em formato de pílula */
  .modes {
    position: static;
    display: inline-grid;
    grid-template-columns: repeat(4, auto);
    border: 1px solid var(--line);
    border-radius: 99px;
    padding: 4px;
    margin-bottom: 22px;
  }
  .modes button { flex-direction: row; gap: 8px; min-height: 40px; padding: 0 18px; border-radius: 99px; font-size: 0.95rem; }
  .modes svg { width: 18px; height: 18px; }
  .modes button[aria-selected="true"] { background: var(--ink); color: var(--bg); }
  .badge { position: static; margin-left: -2px; }

  .word { grid-template-columns: 44px 1fr auto; gap: 4px 14px; padding: 14px 4px; }
  .word .knew { grid-column: 3; grid-row: 1; order: 0; }
  .word .ex { grid-column: 2 / 4; }

  .stage { align-items: center; }
  .card-wrap { max-width: 520px; }
  .card { min-height: 320px; }
  .answer-row .btn { flex: 0 1 auto; min-width: 150px; }
  .next-row { justify-content: flex-end; }
  .next-row .btn { flex: 0 1 auto; min-width: 160px; }

  .chip { border-radius: 99px; padding: 6px 16px; }

  .foot { gap: 6px; }
}

/* Computador: todos os 10 dias cabem na tela, sem rolagem */
@media (min-width: 900px) {
  .days {
    grid-auto-flow: row;
    grid-template-columns: repeat(10, minmax(0, 1fr));
    overflow: visible;
    margin: 0;
    padding: 4px 0 10px;
  }
}

/* Mouse: efeitos de passar o mouse e ajuda de teclado */
@media (hover: hover) and (pointer: fine) {
  .kbd-help { display: block; }
  .search-item:hover { background: var(--cobalt-soft); }
  .tok:hover:not(:disabled):not(.ghost) { background: var(--cobalt-soft); }
  .icon-btn:hover { background: var(--cobalt-soft); }
  .touch-only { display: none; }
  .btn:hover { background: var(--cobalt-soft); }
  .btn.primary:hover { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
  .btn.good:hover { background: var(--ok-soft); filter: brightness(0.97); }
  .btn.again:hover { background: var(--bad-soft); filter: brightness(0.97); }
  .speak:hover { background: var(--cobalt-soft); }
  .option:hover:not(:disabled) { border-color: var(--cobalt); }
  .day-tile:hover:not(.is-active) { border-color: var(--cobalt); }
  .card { cursor: pointer; }
}

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