/* ============================================================
   Flupi App — design system (ciano #03fcdf + violeta)
   ============================================================ */

:root {
  --primary:      #03fcdf; /* ciano da marca: preenchimentos e destaques */
  --primary-dark: #00cfb6; /* borda 3D / hover */
  --primary-deep: #0e7c70; /* texto e links teal sobre branco (5:1) */
  --primary-soft: #d3fdf6; /* fundos suaves */
  --primary-ink:  #043d36; /* texto sobre o ciano (9:1) */
  --violet:       #8b5cf6; /* secundária: estados ativos e apoio */
  --violet-dark:  #7c3aed;
  --violet-soft:  #f0e9ff;
  --blue:        #1cb0f6;
  --blue-dark:   #1899d6;
  --blue-soft:   #ddf4ff;
  --yellow:      #ffc800;
  --yellow-dark: #e6a800;
  --yellow-soft: #fff5d0;
  --red:         #ff4b4b;
  --red-dark:    #ea2b2b;
  --red-soft:    #ffdfe0;
  --purple:      #ce82ff;
  --purple-dark: #a568cc;
  --purple-soft: #f3e0ff;
  --orange:      #ff9600;
  --orange-dark: #e08600;
  --orange-soft: #ffe6c2;

  --text:        #3c3c3c;
  --text-soft:   #777777;
  --text-muted:  #777777; /* alias usado pelo CSS de amigos */
  --muted:       #afafaf;
  --border:      #e5e5e5; /* alias de --line usado pelo CSS de amigos */
  --line:        #e5e5e5;
  --line-strong: #d8d8d8;
  --bg:          #ffffff;
  --bg-soft:     #f7f7f7;

  /* rampa sequencial validada (heatmap) */
  --ramp-1: #35e2cb;
  --ramp-2: #0fb5a0;
  --ramp-3: #0e7c70;
  --ramp-4: #0a4f47;
  --ramp-0: #e9efee;

  --radius: 16px;
  --font: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;

  /* altura estimada da barra de navegação inferior no mobile (padding + item),
     usada para posicionar widgets flutuantes (chat, toasts) acima dela sem
     números mágicos espalhados pelo CSS */
  --mobile-nav-height: 58px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { height: 100%; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

button { font-family: var(--font); }
input, textarea, select { font-family: var(--font); color: var(--text); }

/* ---------- layout ---------- */

#app { display: flex; min-height: 100vh; }
#app[hidden] { display: none; }

#sidebar {
  width: 240px;
  flex-shrink: 0;
  border-right: 2px solid var(--line);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 20px;
}
.logo-mascot { display: flex; align-items: center; }
.logo-text {
  font-size: 28px;
  font-weight: 900;
  color: var(--primary-ink);
  letter-spacing: 0.5px;
}

#nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid transparent;
  text-decoration: none;
  color: var(--text-soft);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  transition: background 0.12s;
}
.nav-item:hover { background: var(--bg-soft); }
.nav-item.active {
  color: var(--violet-dark);
  background: var(--violet-soft);
  border-color: #ddccff;
}
.nav-icon { font-size: 22px; width: 26px; text-align: center; }

#sidebar-stats {
  display: flex;
  gap: 8px;
  padding: 10px 4px 0;
  border-top: 2px solid var(--line);
}
.mini-stat {
  flex: 1;
  text-align: center;
  font-weight: 900;
  font-size: 16px;
  padding: 8px 4px;
  border-radius: 12px;
  background: var(--bg-soft);
}

#main {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 28px calc(80px + env(safe-area-inset-bottom));
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

/* ---------- tipografia ---------- */

h1 { font-size: 30px; font-weight: 900; margin-bottom: 6px; }
h2 { font-size: 21px; font-weight: 900; margin-bottom: 12px; }
.subtitle { color: var(--text-soft); font-weight: 700; margin-bottom: 24px; }

.home-hero {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 22px;
  background: linear-gradient(120deg, #e9fefa, var(--primary-soft) 60%, #f4f0ff);
  border-radius: 26px;
  padding: 20px 26px;
}
.home-hero-avatar { flex: 0 0 auto; line-height: 0; }
.home-hero-text { flex: 1 1 auto; min-width: 0; }
.home-hero-text h1,
.home-hero-text .subtitle { margin-bottom: 0; }
.home-hero-text .subtitle { margin-top: 4px; }

.section { margin-bottom: 34px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.section-head h2 { margin-bottom: 0; }

/* ---------- botões 3D ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 13px 22px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  color: var(--primary-ink);
  background: var(--primary);
  box-shadow: 0 4px 0 var(--primary-dark);
  transition: filter 0.12s, transform 0.05s, box-shadow 0.05s;
  user-select: none;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 transparent; }

.btn-blue   { background: var(--blue);   box-shadow: 0 4px 0 var(--blue-dark); color: #fff; }
.btn-violet { background: var(--violet); box-shadow: 0 4px 0 var(--violet-dark); color: #fff; }
.btn-red    { background: var(--red);    box-shadow: 0 4px 0 var(--red-dark); color: #fff; }
.btn-yellow { background: var(--yellow); box-shadow: 0 4px 0 var(--yellow-dark); color: #7a5b00; }
.btn-purple { background: var(--purple); box-shadow: 0 4px 0 var(--purple-dark); color: #fff; }

.btn-ghost {
  background: #fff;
  color: var(--primary-deep);
  border: 2px solid var(--line);
  box-shadow: 0 4px 0 var(--line);
}
.btn-ghost:active { transform: translateY(4px); box-shadow: 0 0 0 transparent; }

.btn-sm { padding: 9px 16px; font-size: 13px; border-radius: 12px; }
.btn:disabled {
  background: var(--line);
  box-shadow: 0 4px 0 var(--line-strong);
  color: var(--muted);
  cursor: not-allowed;
  filter: none;
}

.icon-btn {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.12s;
}
.icon-btn:hover { background: var(--bg-soft); }

/* ícones SVG minimalistas (js/icons.js) — herdam a cor do texto e escalam
   com a fonte; pointer-events none para o clique cair sempre no botão */
.icon {
  width: 1.15em;
  height: 1.15em;
  display: inline-block;
  vertical-align: -0.2em;
  flex-shrink: 0;
  pointer-events: none;
}
.icon-btn .icon { width: 18px; height: 18px; vertical-align: middle; color: var(--text-soft); }
.icon-btn:hover[data-act="del"] {
  color: var(--red-dark);
  border-color: var(--red);
  background: var(--red-soft);
}
.icon-btn:hover[data-act="del"] .icon { color: inherit; }

/* ---------- superfícies ----------
   sem "caixinha com borda" genérica: superfícies são faixas suaves,
   sem contorno, que se apoiam em cor e espaçamento */

.card {
  border: none;
  border-radius: 20px;
  padding: 22px;
  background: var(--bg-soft);
}

.card-click { cursor: pointer; transition: transform 0.1s, background 0.12s; }
.card-click:hover { background: #f1f1ef; transform: translateY(-2px); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ---------- dashboard ---------- */

/* estatísticas soltas, sem caixa — só ícone + número, estilo Duolingo */
.hero-row { display: flex; justify-content: center; gap: 8px 28px; margin-bottom: 30px; flex-wrap: wrap; }

.stat-tile {
  flex: 0 1 auto;
  min-width: 0;
  border: none;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-emoji { font-size: 26px; }
.stat-value { font-size: 20px; font-weight: 900; line-height: 1.1; }
.stat-label { font-size: 11px; font-weight: 800; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.6px; }

.goal-card {
  display: flex;
  align-items: center;
  gap: 22px;
  border: none;
  border-radius: 22px;
  padding: 22px 26px;
  margin-bottom: 26px;
  background: linear-gradient(135deg, #e9fefa, var(--primary-soft));
}
.goal-info { flex: 1; }
.goal-info h2 { margin-bottom: 4px; }
.goal-info p { color: var(--primary-deep); font-weight: 700; }

/* destaque "continuar estudando": a faixa mais chamativa da home */
.continue-card {
  display: flex;
  align-items: center;
  gap: 16px;
  border: none;
  background: var(--primary);
  border-radius: 22px;
  padding: 22px 24px;
  margin-bottom: 26px;
  box-shadow: 0 5px 0 var(--primary-dark);
}
.continue-card .stat-emoji { font-size: 40px; }
.continue-card .cc-body { flex: 1; }
.continue-card .cc-title { font-weight: 900; font-size: 18px; color: var(--primary-ink); }
.continue-card .cc-sub { color: var(--primary-ink); opacity: 0.75; font-weight: 700; font-size: 14px; }
.continue-card .btn { background: var(--primary-ink); color: var(--primary); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }
.continue-card .level-badge { background: rgba(255, 255, 255, 0.55); color: var(--primary-ink); }

/* ---------- barra de progresso ---------- */

.progress-track {
  height: 16px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  transition: width 0.4s ease;
  min-width: 0;
}
.progress-fill.blue { background: var(--blue); }
.progress-fill.yellow { background: var(--yellow); }
.progress-fill.purple { background: var(--purple); }
.progress-fill.red { background: var(--red); }

/* ---------- temas (linhas fluidas, sem grade de cards) ---------- */

.topic-grid { display: flex; flex-direction: column; }

.topic-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 10px;
  border-bottom: 2px solid var(--bg-soft);
  cursor: pointer;
  border-radius: 14px;
  transition: background 0.12s;
}
.topic-card:hover { background: var(--bg-soft); border-bottom-color: transparent; }
.topic-card:last-child { border-bottom: none; }
.topic-card .topic-emoji {
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin-bottom: 0;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.06);
}
.topic-card .topic-body { flex: 1; min-width: 0; }
.topic-card h3 { font-size: 17px; font-weight: 900; margin-bottom: 2px; overflow-wrap: anywhere; }
.topic-card .topic-meta { color: var(--text-soft); font-weight: 700; font-size: 13px; margin-bottom: 8px; overflow-wrap: anywhere; }
.topic-card .progress-track { max-width: 340px; height: 12px; }
.topic-actions { position: static; display: flex; gap: 6px; opacity: 0; transition: opacity 0.12s; flex-shrink: 0; }
.topic-card:hover .topic-actions { opacity: 1; }

/* tema em geração pela IA: card sem navegação, com barra indeterminada */
.topic-card.generating { cursor: default; }
.topic-card.generating:hover { background: none; border-bottom-color: var(--bg-soft); }
.topic-card.generating .topic-emoji {
  background: var(--primary-soft);
  animation: gen-pulse 1.6s ease-in-out infinite;
}
.topic-card.generating.gen-error .topic-emoji { background: var(--bg-soft); animation: none; }
.gen-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@keyframes gen-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* tema do curso ainda bloqueado (trilha sequencial): sem navegação, cadeado
   por cima do emoji, tudo dessaturado — inclusive os "fantasmas" de níveis
   futuros que o usuário ainda não baixou */
.topic-card.locked { cursor: default; }
.topic-card.locked:hover { background: none; border-bottom-color: var(--bg-soft); }
.topic-card.locked .topic-emoji { filter: grayscale(1); opacity: 0.55; }
.topic-card.locked h3, .topic-card.locked .topic-meta { opacity: 0.55; }
.topic-card.locked .topic-lock {
  position: absolute; left: 44px; top: 44px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-soft); display: flex; align-items: center; justify-content: center;
  font-size: 12px; box-shadow: 0 0 0 2px var(--bg, #fff);
}

/* tema gerado por IA (chat/painel de temas): borda especial, sempre livre —
   não faz parte da trilha sequencial do curso padrão */
.topic-card.ai-generated {
  border: 2px dashed var(--primary, #03fcdf);
  border-bottom: 2px dashed var(--primary, #03fcdf);
  background: var(--primary-soft, rgba(3, 252, 223, 0.06));
}
.topic-card.ai-generated:hover { border-color: var(--primary-deep, #0e7c70); }
.topic-card.ai-generated .topic-ai-badge {
  font-size: 11px; font-weight: 800; letter-spacing: 0.02em;
  color: var(--primary-deep, #0e7c70); background: var(--primary-soft, rgba(3, 252, 223, 0.14));
  border-radius: 8px; padding: 2px 7px; margin-left: 6px; white-space: nowrap;
}
.progress-fill.indeterminate {
  width: 40%;
  animation: gen-indeterminate 1.4s ease-in-out infinite;
}
@keyframes gen-indeterminate {
  0% { margin-left: 0; }
  50% { margin-left: 60%; }
  100% { margin-left: 0; }
}

.add-card {
  border: 2px dashed var(--line-strong);
  border-radius: 18px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 64px;
  margin-top: 10px;
  cursor: pointer;
  color: var(--text-soft);
  font-weight: 800;
  background: none;
  font-size: 15px;
  transition: border-color 0.12s, color 0.12s;
  width: 100%;
}
.add-card:hover { border-color: var(--primary-dark); color: var(--primary-deep); }
.add-card .plus { font-size: 26px; line-height: 1; }

/* ---------- trilha de aulas (detalhe do tema) ----------
   nós circulares grandalhões em zigue-zague, estilo jornada de jogo;
   o deslocamento horizontal (--sway) é calculado por aula em views.js */

.trail { display: flex; flex-direction: column; align-items: center; padding: 18px 0 26px; }
.trail-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  margin-top: 26px;
  transform: translateX(var(--sway, 0px));
  max-width: 260px;
}
.trail-step:first-child { margin-top: 6px; }
.trail-node {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--node-color, var(--primary));
  box-shadow: 0 7px 0 var(--node-shadow, var(--primary-dark)), 0 10px 18px rgba(0, 0, 0, 0.10);
  transition: transform 0.08s, box-shadow 0.08s;
  position: relative;
}
.trail-node:active { transform: translateY(6px); box-shadow: 0 1px 0 var(--node-shadow, var(--primary-dark)); }
.trail-node .trail-check {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--yellow);
  color: #6b5200;
  font-size: 15px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 0 var(--yellow-dark);
}
.trail-step.locked .trail-node {
  background: #ececec;
  box-shadow: 0 7px 0 #d4d4d4;
  filter: grayscale(1);
  opacity: 0.75;
}
.trail-step.current .trail-node { animation: trailPulse 2s ease-in-out infinite; }
.trail-callout {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--violet-dark);
  white-space: nowrap;
  animation: trailFloat 1.6s ease-in-out infinite;
  z-index: 2;
}
.trail-callout::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: #fff;
  border-right: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
}
.trail-label { margin-top: 10px; text-align: center; }
.trail-label .trail-title { font-weight: 900; font-size: 15px; overflow-wrap: anywhere; }
.trail-label .trail-sub { font-size: 12px; font-weight: 700; color: var(--text-soft); }
.trail-actions { display: flex; gap: 6px; margin-top: 8px; opacity: 0; transition: opacity 0.12s; justify-content: center; }
.trail-step:hover .trail-actions, .trail-step:focus-within .trail-actions { opacity: 1; }

@keyframes trailPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes trailFloat {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-5px); }
}

/* ---------- listas (divisores finos no lugar de caixas) ---------- */

.list { display: flex; flex-direction: column; }

.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  border: none;
  border-bottom: 2px solid var(--bg-soft);
  border-radius: 12px;
  padding: 15px 10px;
  background: transparent;
}
.list-item:last-child { border-bottom: none; }
.list-item .li-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--bg-soft);
}
.list-item .li-body { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 900; font-size: 16px; overflow-wrap: anywhere; }
.list-item .li-sub { color: var(--text-soft); font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-actions { display: flex; gap: 6px; flex-shrink: 0; }
.list-item .badge { flex-shrink: 0; }
.list-item.clickable { cursor: pointer; transition: background 0.12s; }
.list-item.clickable:hover { background: var(--bg-soft); border-bottom-color: transparent; }
.list-item.done .li-icon { background: var(--primary-soft); }
.list-item.done .li-title { color: var(--text-soft); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge.green  { background: var(--primary-soft);  color: var(--primary-deep); }
.badge.blue   { background: var(--blue-soft);   color: var(--blue-dark); }
.badge.yellow { background: var(--yellow-soft); color: #8a6d00; }
.badge.purple { background: var(--purple-soft); color: var(--purple-dark); }
.badge.red    { background: var(--red-soft);    color: var(--red-dark); }

/* ---------- abas (pílulas, sem sublinhado) ---------- */

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 22px;
  border: none;
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 5px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}
.tab {
  padding: 9px 18px;
  font-weight: 900;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-soft);
  background: none;
  border: none;
  border-radius: 999px;
  margin-bottom: 0;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.tab.active {
  color: var(--violet-dark);
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  border-bottom-color: transparent;
}

/* ---------- anotações ---------- */

.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }

.note-card {
  border-radius: var(--radius);
  padding: 18px;
  border: 2px solid rgba(0, 0, 0, 0.07);
  cursor: pointer;
  transition: transform 0.1s;
  display: flex;
  flex-direction: column;
  min-height: 140px;
}
.note-card:hover { transform: translateY(-2px); }
.note-card h3 { font-size: 16px; font-weight: 900; margin-bottom: 6px; overflow-wrap: anywhere; }
.note-card .note-body {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
.note-card .note-foot {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 800;
  color: rgba(0, 0, 0, 0.45);
  display: flex;
  justify-content: space-between;
}

.search-input {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 18px;
  outline: none;
}
.search-input:focus { border-color: var(--violet); }

/* ---------- formulários / modal ---------- */

#modal-root:empty { display: none; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 30, 30, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: #fff;
  border-radius: 20px;
  padding: 26px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: popIn 0.18s ease;
}
.modal h2 { margin-bottom: 18px; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.94); } }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.field input[type="text"], .field input[type="number"], .field input[type="email"], .field input[type="password"], .field textarea, .field select {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 15px;
  font-weight: 700;
  outline: none;
  background: #fff;
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--violet); }

.password-field { position: relative; }
.password-field input[type="password"], .password-field input[type="text"] { padding-right: 44px; }
.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  border-radius: 8px;
}
.password-toggle:hover { color: var(--text); }
.password-toggle svg { width: 20px; height: 20px; }
.password-toggle .icon-eye-off { display: none; }
.password-toggle[aria-pressed="true"] .icon-eye { display: none; }
.password-toggle[aria-pressed="true"] .icon-eye-off { display: block; }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 700; margin-top: 4px; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.emoji-row { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-opt {
  width: 42px;
  height: 42px;
  font-size: 22px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}
.emoji-opt.selected { border-color: var(--primary); background: var(--primary-soft); }

.color-row { display: flex; flex-wrap: wrap; gap: 8px; }
.color-opt {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
}
.color-opt.selected { border-color: var(--text); }

/* ---------- prática (sessão) ---------- */

.practice-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh; /* fallback for browsers without dvh/svh support */
  height: 100svh; /* small viewport height: stays consistent even when the mobile keyboard/URL bar appears */
  background: #fff;
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 100vw;
}
.practice-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  padding-top: calc(18px + env(safe-area-inset-top));
  padding-left: calc(24px + env(safe-area-inset-left));
  padding-right: calc(24px + env(safe-area-inset-right));
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  flex: 0 0 auto;
  box-sizing: border-box;
}
.practice-quit {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}
.practice-quit:hover { color: var(--text-soft); }
.practice-bar { flex: 1; }
.practice-avatar-wrap { position: relative; flex: 0 0 auto; line-height: 0; min-height: 32px; min-width: 32px; }
.practice-avatar { flex: 0 0 auto; line-height: 0; }
.practice-hearts {
  position: absolute;
  right: -6px;
  bottom: -4px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 900;
  font-size: 12px;
  color: var(--red);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
  box-shadow: 0 2px 0 var(--line);
}

.practice-body {
  flex: 1 1 auto;
  min-height: 0; /* allow this flex child to actually shrink/scroll instead of forcing the screen taller */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px 40px;
  padding-left: calc(24px + env(safe-area-inset-left));
  padding-right: calc(24px + env(safe-area-inset-right));
  max-width: 680px;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}
.practice-kind { font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; color: var(--purple-dark); margin-bottom: 10px; }
.practice-question { font-size: 24px; font-weight: 900; margin-bottom: 26px; line-height: 1.35; overflow-wrap: break-word; word-break: break-word; }

.choice-list { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.choice {
  width: 100%;
  min-height: 48px;
  text-align: left;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 15px 18px;
  font-size: 17px;
  font-weight: 700;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--line);
  transition: background 0.1s;
  overflow-wrap: break-word;
  word-break: break-word;
  box-sizing: border-box;
}
.choice:hover { background: var(--bg-soft); }
.choice.selected { border-color: var(--violet); background: var(--violet-soft); box-shadow: 0 3px 0 #d5c5fb; color: var(--violet-dark); }
.choice.correct { border-color: var(--primary-dark); background: var(--primary-soft); box-shadow: 0 3px 0 #8ee9db; color: var(--primary-deep); }
.choice.wrong { border-color: var(--red); background: var(--red-soft); box-shadow: 0 3px 0 #f0a5a5; color: var(--red-dark); }
.choice:disabled { cursor: default; }

.type-input {
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  font-size: 18px;
  font-weight: 700;
  outline: none;
  box-sizing: border-box;
}
.type-input:focus { border-color: var(--violet); }

.flashcard {
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 46px 30px;
  text-align: center;
  font-size: 26px;
  font-weight: 900;
  cursor: pointer;
  background: #fff;
  box-shadow: 0 4px 0 var(--line);
  margin-bottom: 22px;
  min-height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
  overflow-wrap: break-word;
  word-break: break-word;
  box-sizing: border-box;
}
.flashcard:hover { transform: translateY(-2px); }
.flashcard .fc-hint { display: block; font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 14px; }
.flashcard.flipped { background: var(--purple-soft); border-color: var(--purple); box-shadow: 0 4px 0 var(--purple); }

.self-grade { display: flex; gap: 12px; }
.self-grade .btn { flex: 1; min-height: 48px; }
/* sem esta regra, o display:flex acima sobrescreve o atributo [hidden] do
   navegador e o botão "Ouvir pronúncia" fica sobreposto pelos botões de
   autoavaliação, que aparecem antes da hora (antes do card ser virado) */
.self-grade[hidden] { display: none; }

.practice-foot {
  border-top: 2px solid var(--line);
  padding: 18px 24px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  padding-left: calc(24px + env(safe-area-inset-left));
  padding-right: calc(24px + env(safe-area-inset-right));
  background: #fff;
  flex: 0 0 auto;
  box-sizing: border-box;
}
.practice-foot.correct { background: var(--primary-soft); border-color: transparent; }
.practice-foot.wrong { background: var(--red-soft); border-color: transparent; }
.practice-foot-inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.feedback { flex: 1 1 200px; min-width: 0; }
.feedback .fb-title { font-size: 20px; font-weight: 900; }
.feedback.good .fb-title { color: var(--primary-deep); }
.feedback.bad .fb-title { color: var(--red-dark); }
.feedback .fb-sub { font-weight: 700; color: var(--text-soft); font-size: 15px; overflow-wrap: break-word; word-break: break-word; }
.practice-foot-inner .btn { min-height: 48px; }

/* tela de resultado */
.result-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}
.result-screen .big-emoji { font-size: 72px; }
.result-screen h1 { font-size: 34px; }
.result-stats { display: flex; gap: 14px; margin: 22px 0 28px; flex-wrap: wrap; justify-content: center; }
.result-pill {
  border: 2px solid;
  border-radius: 16px;
  padding: 4px;
  min-width: 130px;
  max-width: 100%;
  overflow: hidden;
}
.result-screen #pr-finish { width: 100%; max-width: 320px; min-height: 48px; }
.result-pill .rp-label { font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.8px; color: #fff; padding: 4px 10px 6px; }
.result-pill .rp-value { background: #fff; border-radius: 12px; font-size: 22px; font-weight: 900; padding: 10px; }
.result-pill.gold { border-color: var(--yellow); background: var(--yellow); }
.result-pill.gold .rp-value { color: var(--yellow-dark); }
.result-pill.green { border-color: var(--primary); background: var(--primary); }
.result-pill.green .rp-label { color: var(--primary-ink); }
.result-pill.green .rp-value { color: var(--primary-deep); }
.result-pill.blue { border-color: var(--blue); background: var(--blue); }
.result-pill.blue .rp-value { color: var(--blue-dark); }

/* ---------- aula (leitura) ---------- */

.lesson-content {
  position: relative; /* âncora dos retângulos .word-select-highlight */
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 30px;
  font-size: 16px;
  line-height: 1.7;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.lesson-content h1, .lesson-content h2, .lesson-content h3 { margin: 18px 0 8px; }
.lesson-content h1:first-child, .lesson-content h2:first-child, .lesson-content h3:first-child { margin-top: 0; }
.lesson-content ul { margin: 8px 0 8px 22px; }
.lesson-content li { margin-bottom: 4px; }
.lesson-content p { margin-bottom: 10px; }
.lesson-content code {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.lesson-content strong { color: var(--primary-deep); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
  font-weight: 800;
  text-decoration: none;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}
.back-link:hover { color: var(--primary-deep); }

/* ---------- progresso / gráficos ---------- */

.viz-card {
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
}
.viz-card h2 { font-size: 17px; margin-bottom: 16px; }
.viz-card .viz-sub { font-size: 13px; color: var(--text-soft); font-weight: 700; margin-top: -12px; margin-bottom: 14px; }

.viz-tooltip {
  position: fixed;
  z-index: 200;
  background: var(--text);
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 11px;
  border-radius: 10px;
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}

.xpbars-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.xpbars-scroll svg { display: block; }

.word-popup {
  position: fixed;
  z-index: 250;
  background: var(--text);
  color: #fff;
  font-family: var(--font);
  padding: 8px 12px;
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  max-width: min(320px, calc(100vw - 24px));
}
.word-popup[hidden] { display: none; }
.word-popup-ipa {
  font-family: 'Segoe UI', Arial, 'Noto Sans', sans-serif;
  font-size: 14px;
  font-weight: 800;
  white-space: normal;
  overflow-wrap: anywhere;
}
.word-popup-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}
.word-popup-translation {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.65;
  overflow-wrap: anywhere;
}
.word-popup-speak {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.word-popup-speak:hover { background: rgba(255, 255, 255, 0.28); }
.word-popup-speak:disabled { opacity: 0.5; cursor: default; }
.word-popup-save {
  flex-shrink: 0;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  border: none;
  background: var(--primary);
  color: var(--primary-ink);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.word-popup-save:hover { filter: brightness(1.08); }
.word-popup-save:disabled { opacity: 0.5; cursor: default; filter: none; }
.word-popup-save[hidden] { display: none; }
.word-popup-highlight {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.word-popup-highlight:hover { background: rgba(255, 255, 255, 0.28); }
.word-popup-highlight:disabled { opacity: 0.5; cursor: default; }
.word-popup-highlight[hidden] { display: none; }

/* vocabulário extraído de uma frase selecionada */
.word-popup-vocab {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}
.word-popup-vocab[hidden] { display: none; }
.word-popup-vocab-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.6;
  margin-bottom: 2px;
}
.word-popup-vocab-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-family: var(--font);
  font-size: 12px;
  padding: 7px 9px;
  cursor: pointer;
}
.word-popup-vocab-item:hover { background: rgba(255, 255, 255, 0.22); }
.word-popup-vocab-item:disabled { cursor: default; }
.word-popup-vocab-item.saved { opacity: 0.55; }
.word-popup-vocab-item .wpv-plus { flex-shrink: 0; }
.word-popup-vocab-item .wpv-text { font-weight: 800; white-space: nowrap; }
.word-popup-vocab-item .wpv-level {
  font-size: 10px;
  font-weight: 900;
  opacity: 0.7;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  padding: 0 5px;
  margin-left: 2px;
}
.word-popup-vocab-item .wpv-translation { opacity: 0.65; overflow-wrap: anywhere; }
.word-popup-vocab-all {
  margin-top: 4px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-ink);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 800;
  padding: 8px;
  cursor: pointer;
}
.word-popup-vocab-all:hover { filter: brightness(1.08); }

.heatmap-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; max-width: 100%; }
.heatmap-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); gap: 3px; width: max-content; }
.heat-cell { width: 14px; height: 14px; border-radius: 4px; background: var(--ramp-0); }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
}
.heatmap-legend .heat-cell { display: inline-block; }

.achievement-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.achievement {
  border: none;
  background: var(--bg-soft);
  border-radius: 18px;
  padding: 16px 12px;
  text-align: center;
}
.achievement .ach-emoji { font-size: 34px; filter: grayscale(1); opacity: 0.35; }
.achievement .ach-name { font-weight: 900; font-size: 14px; margin-top: 6px; overflow-wrap: anywhere; }
.achievement .ach-desc { font-size: 12px; font-weight: 700; color: var(--text-soft); margin-top: 2px; overflow-wrap: anywhere; }
.achievement.unlocked { border-color: var(--yellow); background: var(--yellow-soft); }
.achievement.unlocked .ach-emoji { filter: none; opacity: 1; }

.level-card { display: flex; align-items: center; gap: 20px; }
.level-ring { flex-shrink: 0; }
.level-body { flex: 1; }
.level-body .level-title { font-size: 22px; font-weight: 900; }
.level-body .level-sub { color: var(--text-soft); font-weight: 700; font-size: 14px; margin-bottom: 10px; }

.topic-progress-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 2px solid var(--bg-soft); }
.topic-progress-row:last-child { border-bottom: none; }
.topic-progress-row .tp-emoji { font-size: 22px; }
.topic-progress-row .tp-name { font-weight: 800; width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-progress-row .progress-track { flex: 1; height: 12px; }
.topic-progress-row .tp-pct { font-weight: 900; font-size: 13px; color: var(--text-soft); width: 68px; text-align: right; }

/* ---------- toast ---------- */

#toast-root {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--text);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  padding: 13px 22px;
  border-radius: 14px;
  animation: toastIn 0.25s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}
.toast.gold { background: var(--yellow); color: #6b5200; }
.toast.green { background: var(--primary); color: var(--primary-ink); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } }

/* ---------- modal de upgrade (Flupi+) ---------- */

.upgrade-modal { text-align: center; }
.upgrade-modal-emoji {
  font-size: 44px;
  margin: 0 auto 6px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--violet-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.upgrade-modal h2 { margin-bottom: 6px; }
.upgrade-modal-msg { font-weight: 700; color: var(--text-soft); margin-bottom: 14px; }
.upgrade-modal-perks {
  list-style: none;
  text-align: left;
  background: var(--bg-soft);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
}

/* ---------- confete ---------- */

#confetti-root { position: fixed; inset: 0; pointer-events: none; z-index: 400; overflow: hidden; }
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 14px;
  top: -20px;
  border-radius: 3px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.6; }
}

/* ---------- vazio ---------- */

.empty-state {
  text-align: center;
  padding: 46px 20px;
  border: none;
  border-radius: 22px;
  background: var(--bg-soft);
  color: var(--text-soft);
}
.empty-state .empty-emoji { font-size: 46px; margin-bottom: 10px; }
.empty-state p { font-weight: 700; margin-bottom: 16px; }

.empty-state.loading-state { border: none; }
.loading-spinner {
  width: 30px;
  height: 30px;
  margin: 0 auto 14px;
  border: 3px solid var(--line-strong);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: loadingSpin 0.8s linear infinite;
}
@keyframes loadingSpin {
  to { transform: rotate(360deg); }
}

/* tela de loading do teste de nivelamento: sem a borda tracejada do
   .empty-state genérico, com um ícone temático por frase no lugar do spinner */
.placement-loading { border: none; }
.pl-loading-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: plIconPulse 1.6s ease-in-out infinite;
}
.pl-loading-icon svg { width: 32px; height: 32px; }
.pl-icon-blue   { background: var(--blue-soft);   color: var(--blue); }
.pl-icon-green  { background: var(--primary-soft);  color: var(--primary-dark); }
.pl-icon-yellow { background: var(--yellow-soft); color: var(--yellow-dark); }
@keyframes plIconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ---------- chatbot flutuante ---------- */

#chatbot-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}
#chatbot-root[hidden] { display: none; }

#chatbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--blue);
  box-shadow: 0 4px 0 var(--blue-dark), 0 6px 14px rgba(0,0,0,0.18);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  transition: transform 0.12s;
}
#chatbot-toggle:hover { transform: scale(1.06); }
#chatbot-toggle:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--blue-dark); }

#chatbot-panel {
  position: relative;
  width: 340px;
  max-width: calc(100vw - 32px);
  height: 460px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chatbot-header {
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chatbot-header-actions { display: flex; align-items: center; gap: 4px; }
#chatbot-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.85;
}
#chatbot-header button:hover { opacity: 1; }

#chatbot-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-soft);
}
.chatbot-history-empty {
  color: var(--text-soft);
  font-size: 14px;
  text-align: center;
  padding: 30px 10px;
}
.chatbot-history-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  text-align: left;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.chatbot-history-item:hover { border-color: var(--blue); }
.chatbot-history-title { font-weight: 800; font-size: 14px; color: var(--text); }
.chatbot-history-date { font-size: 11px; color: var(--text-soft); }

#chatbot-messages {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-soft);
}

/* em telas de toque a seleção nativa (arrastar para selecionar) dispara a
   barra flutuante do sistema (copiar/colar/selecionar tudo), que fica por
   cima de qualquer UI da página e cobre nosso popup de pronúncia. Por isso
   desabilitamos a seleção nativa aqui e implementamos a própria (ver
   setupWordPopup em chatbot.js), com este overlay simulando o destaque. */
@media (hover: none) and (pointer: coarse) {
  .chatbot-msg-assistant,
  .doc-page-text,
  .lesson-content {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    /* remove o atraso/zoom nativo de duplo toque, usado para selecionar palavra */
    touch-action: manipulation;
  }
}
.word-select-highlight {
  position: absolute;
  background: rgba(28, 176, 246, 0.35);
  border-radius: 2px;
  pointer-events: none;
  z-index: 5;
}

/* ---------- leitor de documentos (Biblioteca > Documentos) ---------- */
/* mobile-first: uma coluna de leitura de largura total, com a barra de
   navegação de página no fluxo normal (não fixa) para nunca cobrir texto
   nem disputar espaço com a barra de navegação do app no rodapé do celular;
   telas maiores só ganham uma coluna central mais estreita, ver ≥760px abaixo */
.doc-reader-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.doc-reader-title {
  flex: 1;
  min-width: 0;
  font-weight: 900;
  font-size: 17px;
  overflow-wrap: anywhere;
}
.doc-page-text {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 40vh;
}
.doc-highlight {
  background: rgba(255, 214, 51, 0.55);
  border-radius: 2px;
  color: inherit;
}
.doc-block-paragraph { margin: 0 0 16px; }
.doc-block-paragraph:last-child { margin-bottom: 0; }
.doc-block-heading {
  font-size: 1.3em;
  font-weight: 900;
  line-height: 1.35;
  margin: 26px 0 12px;
}
.doc-block-heading:first-child { margin-top: 0; }
.doc-block-stanza {
  margin: 0 0 20px;
  padding-left: 18px;
  border-left: 3px solid var(--line);
  font-style: italic;
  color: var(--text-soft);
}
.doc-reader-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.doc-reader-nav button { min-height: 44px; }
.doc-reader-count {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  font-weight: 800;
  font-size: 13px;
  color: var(--blue);
  text-decoration: underline;
  white-space: nowrap;
  cursor: pointer;
}
.doc-reader-complete-btn { width: 100%; margin-top: 12px; }

.doc-page-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
  margin-top: 12px;
}
.doc-page-picker-item {
  min-height: 44px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}
.doc-page-picker-item:hover { background: var(--bg-soft); }
.doc-page-picker-item.completed { background: var(--primary-soft); border-color: var(--primary-dark); }
.doc-page-picker-item.current { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }

@media (min-width: 760px) {
  .doc-reader { max-width: 720px; margin: 0 auto; }
}

.chatbot-msg {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.chatbot-msg-assistant {
  align-self: flex-start;
  background: #fff;
  border: 2px solid var(--line);
  color: var(--text);
}
.chatbot-msg-user {
  align-self: flex-end;
  background: var(--blue-soft);
  border: 2px solid #84d8ff;
  color: var(--text);
}
.chatbot-typing { opacity: 0.6; font-style: italic; }
.chatbot-correction-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 8px;
}
.chatbot-correction-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 12px;
  border: none;
  background: var(--primary-soft);
  color: var(--primary-deep);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.chatbot-correction-chip .ccc-mark { flex-shrink: 0; }
.chatbot-correction-chip .ccc-text { overflow-wrap: anywhere; }
.chatbot-correction-chip:hover { filter: brightness(0.95); }
.chatbot-correction-chip:disabled,
.chatbot-correction-chip.saved { opacity: 0.6; cursor: default; filter: none; }
.chatbot-correction-save-all {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0 2px;
}
.chatbot-correction-save-all:hover { color: var(--text); }
.chatbot-suggestions {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: 85%;
}
.chatbot-suggestions-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
}
.chatbot-suggestion-chip {
  max-width: 100%;
  padding: 6px 12px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.chatbot-suggestion-chip:hover:not(:disabled) { background: var(--blue-soft); border-color: #84d8ff; }
.chatbot-suggestion-chip:disabled { opacity: 0.5; cursor: default; }
.chatbot-msg.chatbot-chart { max-width: 100%; align-self: stretch; }
.chatbot-msg.chatbot-audio {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  width: 240px;
  max-width: 100%;
}
.chatbot-audio-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chatbot-audio-transcript {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text-soft);
  opacity: 0.65;
  padding-left: 44px;
  white-space: pre-wrap;
}
.chatbot-audio-transcript[hidden] { display: none; }
.chatbot-audio-play {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chatbot-audio-play.playing { background: var(--primary-dark); }
.chatbot-audio-track {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  cursor: pointer;
  overflow: hidden;
}
.chatbot-audio-progress {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: var(--primary);
  transition: width 0.1s linear;
}
.chatbot-audio-time {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  min-width: 30px;
  text-align: right;
}

#chatbot-form,
#chatbot-audio-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border-top: 2px solid var(--line);
  background: #fff;
}
#chatbot-audio-preview .chatbot-audio-track { flex: 1; }
#chatbot-audio-discard,
#chatbot-audio-confirm {
  border: none;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#chatbot-audio-discard { background: var(--bg-soft); }
#chatbot-audio-discard:hover { background: var(--red-soft, #ffe0e0); }
#chatbot-audio-confirm { background: var(--primary); color: var(--primary-ink); }
#chatbot-form input {
  flex: 1;
  min-width: 0;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
}
#chatbot-form input:focus { border-color: var(--violet); }

/* mic e conversa ao vivo: botões minimalistas (só o ícone, sem preenchimento),
   no estilo das barras de input do ChatGPT/Claude */
#chatbot-mic, #chatbot-send, #chatbot-live-start {
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
#chatbot-mic, #chatbot-live-start {
  background: transparent;
  color: var(--text-soft);
}
#chatbot-mic svg, #chatbot-live-start svg { width: 19px; height: 19px; }
#chatbot-mic:hover, #chatbot-live-start:hover { background: var(--bg-soft); color: var(--text); }
#chatbot-live-start:hover { color: var(--blue); }
#chatbot-send { background: var(--primary); color: var(--primary-ink); font-size: 16px; }
#chatbot-mic.recording { background: var(--red); color: #fff; animation: pulse 1s infinite; }

/* modo ao vivo é 100% Flupi+: cadeado no canto do botão pra quem é grátis
   (continua clicável — o clique abre o modal de upgrade, não é disabled) */
#chatbot-live-start.locked { position: relative; }
#chatbot-live-start.locked::after {
  content: '🔒';
  position: absolute;
  bottom: -2px;
  right: -2px;
  font-size: 9px;
  line-height: 1;
  background: #fff;
  border-radius: 50%;
  padding: 1px;
  box-shadow: 0 0 0 1px var(--line);
}

/* barra de uso do plano grátis, entre as mensagens e o campo de digitação */
.chatbot-usage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 14px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-soft);
  background: var(--bg-soft);
  border-top: 1px solid var(--line);
}
.chatbot-usage-bar[hidden] { display: none; }
#chatbot-usage-upgrade {
  border: none;
  background: none;
  color: var(--violet-dark);
  font-weight: 900;
  font-size: 11.5px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}
#chatbot-usage-upgrade:hover { background: var(--violet-soft); }

#chatbot-mic:disabled,
#chatbot-send:disabled,
#chatbot-live-start:disabled,
#chatbot-audio-confirm:disabled,
#chatbot-audio-discard:disabled,
#chatbot-form input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ---------- modo de conversa ao vivo ----------
   overlay imersivo (estilo ChatGPT/Claude voice mode): cobre todo o painel
   do chat, sem precisar de nenhum botão por turno — a detecção de início/fim
   de fala é feita via nível de áudio do microfone (ver setupLiveMode em
   chatbot.js), a orbe reage em tempo real ao volume de quem está falando
   (usuário ou a própria resposta em áudio da IA). */
#chatbot-live-panel {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 20px;
  background: radial-gradient(ellipse at center, #16213a 0%, #05070d 75%);
  border-radius: inherit;
}
#chatbot-live-exit {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 14px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
#chatbot-live-exit:hover { background: rgba(255, 255, 255, 0.22); }

#chatbot-live-orb {
  --level: 0;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 38% 32%, #ffffff 0%, #bfe9ff 22%, #4fb8f5 55%, #1a63c9 100%);
  box-shadow: 0 0 calc(20px + var(--level) * 60px) calc(4px + var(--level) * 18px) rgba(79, 184, 245, 0.55);
  transform: scale(calc(1 + var(--level) * 0.22));
  transition: transform 90ms ease-out, box-shadow 90ms ease-out;
  flex-shrink: 0;
}
#chatbot-live-orb.is-processing {
  animation: live-orb-processing 1.1s ease-in-out infinite;
}
#chatbot-live-orb.is-speaking { cursor: pointer; }
.chatbot-live-orb-core {
  width: 60%;
  height: 60%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.9), rgba(255,255,255,0) 70%);
}

@keyframes live-orb-processing {
  0%, 100% { transform: scale(0.92); opacity: 0.75; }
  50% { transform: scale(1.05); opacity: 1; }
}

#chatbot-live-status {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.02em;
}

#chatbot-live-caption {
  max-width: 100%;
  text-align: center;
  min-height: 20px;
}
#chatbot-live-caption-user {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}
#chatbot-live-caption-assistant {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  overflow-wrap: anywhere;
}

#chatbot-panel[hidden],
#chatbot-messages[hidden],
#chatbot-form[hidden],
#chatbot-live-panel[hidden],
#chatbot-audio-preview[hidden],
#chatbot-history-list[hidden] { display: none; }


/* ---------- nível CEFR e revisão espaçada ---------- */

.level-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.level-a1 { background: #d3fdf6; color: #0e7c70; }
.level-a2 { background: #ddf4ff; color: #1390cc; }
.level-b1 { background: #e9e4ff; color: #6d4fd8; }
.level-b2 { background: #f3e8ff; color: #a25ddc; }
.level-c1 { background: #fff0d9; color: #cc7800; }
.level-c2 { background: #ffe3e3; color: #d63333; }
.level-badge.pending { background: var(--bg-soft); color: var(--muted); }

/* card "Revisões de hoje" no hub Praticar */
.review-card { background: linear-gradient(135deg, #fff9ec, #fff1d6); }
.review-card p { color: #8a6d00; }
.review-card-done { background: linear-gradient(135deg, #e9fefa, var(--primary-soft)); }

/* flashcard de palavra na revisão */
.flashcard .fc-ipa {
  display: block;
  font-family: 'Segoe UI', Arial, 'Noto Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-soft);
  margin-top: 8px;
}
.word-review-tools { display: flex; justify-content: center; margin-top: 14px; }
.wd-ipa { font-size: 12px; font-weight: 700; color: var(--text-soft); }
/* frase de origem da palavra (contexto de exemplo) */
.flashcard .fc-context {
  display: block;
  font-size: 15px;
  font-weight: 600;
  font-style: italic;
  color: var(--text-soft);
  margin-top: 10px;
}
.wd-context { font-style: italic; opacity: 0.8; }

/* faixa de nível estimado (home/progresso) */
.user-level-card { display: flex; align-items: center; gap: 18px; }
.user-level-badge {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  background: var(--violet);
  box-shadow: 0 4px 0 var(--violet-dark);
  flex-shrink: 0;
}
.user-level-body { flex: 1; min-width: 0; }
.user-level-title { font-weight: 900; font-size: 18px; }
.user-level-sub { font-size: 13px; font-weight: 700; color: var(--text-soft); margin-bottom: 8px; }

/* barras de domínio por nível (progresso) */
.cefr-row { display: flex; align-items: center; gap: 14px; padding: 8px 0; }
.cefr-row .progress-track { flex: 1; height: 12px; }
.cefr-row .cefr-count { font-size: 12px; font-weight: 800; color: var(--text-soft); min-width: 64px; text-align: right; }

/* agrupamento de temas por nível */
.level-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 26px 0 14px;
}
.level-section-head h2 { margin: 0; }
.level-section-head:first-of-type { margin-top: 8px; }


/* ---------- responsivo ---------- */

@media (max-width: 1024px) and (min-width: 761px) {
  #sidebar { width: 84px; padding: 16px 8px; }
  .logo-text { display: none; }
  .nav-item span:not(.nav-icon) { display: none; }
  .nav-item { justify-content: center; }
  #sidebar-stats { flex-direction: column; }
}

@media (max-width: 760px) {
  html, body { overflow-x: hidden; }
  #app { flex-direction: column; overflow-x: hidden; }
  #sidebar {
    position: fixed;
    bottom: 0;
    top: auto;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-top: 2px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: #fff;
    z-index: 40;
  }
  #sidebar .logo, #sidebar-stats { display: none; }
  #nav { flex-direction: row; justify-content: space-around; width: 100%; }
  .nav-item {
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
    font-size: 10px;
    letter-spacing: 0;
    border: none;
    flex: 1;
    min-width: 0;
    min-height: 44px;
    justify-content: center;
  }
  .nav-item.active { border: none; }
  .nav-item span:not(.nav-icon) {
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #main { padding: 20px 16px calc(110px + env(safe-area-inset-bottom)); overflow-x: hidden; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topic-progress-row .tp-name { width: 110px; }
  .practice-top { padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top)); padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); gap: 12px; }
  .practice-body { padding: 16px 16px 28px; padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); }
  .practice-question { font-size: 20px; margin-bottom: 20px; }
  .flashcard { padding: 30px 20px; min-height: 130px; font-size: 22px; }
  .practice-foot { padding: 14px 16px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); }
  .practice-foot-inner { gap: 12px; }
  .practice-foot-inner .btn { flex: 1 1 100%; }
  #chatbot-root { right: 14px; bottom: calc(var(--mobile-nav-height) + 20px + env(safe-area-inset-bottom)); }
  #toast-root { bottom: calc(var(--mobile-nav-height) + 32px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); }
  .icon-btn, .emoji-opt { width: 44px; height: 44px; }
  .btn { min-height: 44px; }

  /* modal: linha de ações empilhada (evita botões cortados/espremidos) */
  .modal-actions {
    flex-wrap: wrap;
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .modal-actions .btn { width: 100%; }

  /* chatbot: alvos de toque maiores e sem zoom automático no iOS ao focar o input */
  #chatbot-header button {
    min-width: 44px;
    min-height: 44px;
    padding: 4px;
    font-size: 18px;
  }
  .chatbot-header-actions { gap: 2px; }
  #chatbot-mic, #chatbot-send, #chatbot-live-start { width: 40px; height: 40px; font-size: 18px; }
  #chatbot-mic svg, #chatbot-live-start svg { width: 20px; height: 20px; }
  #chatbot-form { gap: 4px; padding: 8px; }
  #chatbot-form input { font-size: 16px; padding: 8px 10px; }
  .chatbot-msg { font-size: 15px; }
  .chatbot-history-date { font-size: 12px; }
}

/* ---------- mobile-first: views (temas / aulas / anotações / progresso) ---------- */

@media (max-width: 600px) {
  .topic-grid,
  .notes-grid,
  .achievement-grid {
    grid-template-columns: 1fr;
  }

  .hero-row { gap: 8px 18px; }
  .stat-tile { min-width: 0; }

  .goal-card {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
    padding: 20px;
  }
  .goal-card > .btn { width: 100%; }

  .continue-card { flex-wrap: wrap; }
  .continue-card .cc-body { flex-basis: 100%; min-width: 0; }
  .continue-card > .btn { width: 100%; }

  .level-card { flex-direction: column; text-align: center; }

  .list-item { flex-wrap: wrap; row-gap: 10px; }
  .list-item .li-body { flex-basis: 60%; }
  .list-item .li-sub { white-space: normal; overflow-wrap: anywhere; }
  .list-item .li-actions { margin-left: auto; }

  .topic-progress-row { flex-wrap: wrap; row-gap: 6px; }
  .topic-progress-row .tp-name { width: auto; flex: 1 1 auto; }
  .topic-progress-row .progress-track { flex-basis: 100%; order: 3; }

  .lesson-content { padding: 20px 18px; }

  .tabs { flex-wrap: wrap; gap: 4px; }
  .tab { flex: 1 1 calc(50% - 4px); padding: 8px 6px; font-size: 12px; text-align: center; }
}


@media (max-width: 480px) {
  #main { padding-left: 12px; padding-right: 12px; }
  h1 { font-size: 24px; }
  h2 { font-size: 18px; }
  .home-hero-avatar svg { width: 92px; height: 110px; }
  .modal-overlay { padding: 8px; align-items: flex-end; }
  .modal { padding: 18px 16px; max-height: calc(100dvh - 16px); width: 100%; border-radius: 20px 20px 0 0; }
  .practice-top { padding: 12px; padding-top: calc(12px + env(safe-area-inset-top)); gap: 10px; }
  .practice-hearts { font-size: 14px; }
  .practice-body { padding: 14px 12px 24px; }
  .practice-question { font-size: 18px; }
  .choice { padding: 13px 14px; font-size: 15px; }
  .flashcard { padding: 24px 16px; font-size: 20px; }
  .result-screen .big-emoji { font-size: 56px; }
  .result-screen h1 { font-size: 26px; }
  .result-pill { min-width: 100px; }

  /* chatbot: painel quase fullscreen em telas pequenas, ancorado à
     visualViewport (ajustada via JS em chatbot.js) para não ficar atrás
     do teclado virtual */
  #chatbot-root { right: 8px; bottom: calc(var(--mobile-nav-height) + 16px + env(safe-area-inset-bottom)); }
  #chatbot-panel {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    height: min(560px, calc(100dvh - var(--mobile-nav-height) - 32px));
    max-height: calc(100dvh - var(--mobile-nav-height) - 32px);
  }
}

/* ---------- tela de login / cadastro ---------- */

#auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #e9fefa 0%, var(--primary-soft) 55%, #f4f0ff 100%);
  padding: 20px;
  overflow-y: auto;
  box-sizing: border-box;
}
#auth-screen[hidden] { display: none; }

.auth-card {
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--bg);
  border: none;
  border-radius: 24px;
  padding: 32px 28px;
  box-sizing: border-box;
  box-shadow: 0 16px 40px rgba(4, 61, 54, 0.14);
}

@media (max-width: 480px) {
  #auth-screen { padding: 12px; }
  .auth-card { padding: 24px 18px; }
}

@media (max-height: 560px) {
  #auth-screen { align-items: flex-start; padding-top: 16px; }
  .auth-subtitle { margin: 6px 0 16px; }
  .field { margin-bottom: 12px; }
}

.auth-logo { justify-content: center; margin-bottom: 4px; }

.auth-subtitle {
  color: var(--text-soft);
  font-weight: 700;
  text-align: center;
  font-size: 14px;
  margin: 8px 0 24px;
}

.auth-invite-banner {
  background: var(--cyan-soft, #e6fffb);
  border: 1px solid var(--cyan, #03fcdf);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  margin: -8px 0 16px;
}

#auth-form .btn { width: 100%; margin-top: 4px; }

.auth-error {
  color: var(--red-dark);
  background: var(--red-soft);
  font-weight: 700;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 14px;
}

.auth-toggle {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-soft);
  font-weight: 700;
}

.auth-link {
  background: none;
  border: none;
  color: var(--violet-dark);
  font-weight: 800;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  margin-left: 4px;
}
.auth-link:hover { text-decoration: underline; }

/* ============================================================
   Avatar — SVG modular + estados de animação
   ============================================================ */

.profile-header { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.profile-header-text { display: flex; flex-direction: column; gap: 6px; }
.profile-header-text h1 { margin: 0; }
#profile-avatar-preview { flex: 0 0 auto; line-height: 0; }

/* ---------- Planos (grátis x Flupi+) ---------- */

/* card "Seu plano" (Ajustes): badge + barras de uso ou selo premium */
.plan-card { position: relative; }
.plan-card-badge {
  display: inline-block;
  font-weight: 900;
  font-size: 13px;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 12px;
  background: var(--violet-soft);
  color: var(--violet-dark);
}
.plan-card-badge-free { background: var(--bg-soft); color: var(--text-soft); }
.plan-card-premium { background: linear-gradient(120deg, var(--violet-soft), #f4f0ff); }
.usage-rows { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.usage-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 800;
  font-size: 13.5px;
  margin-bottom: 6px;
}
.usage-row-count { color: var(--text-soft); font-size: 12px; font-weight: 700; }

/* hero + preços da página #/planos */
.plans-hero { text-align: center; margin-bottom: 22px; }
.plans-hero-emoji {
  font-size: 40px;
  width: 76px;
  height: 76px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: var(--violet-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.plans-hero h1 { margin-bottom: 4px; }
.plans-pricing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  max-width: 480px;
  margin: 0 auto;
}
.plan-price-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 4px 0 var(--line-strong);
}
.plan-price-featured { border-color: var(--violet); box-shadow: 0 4px 0 var(--violet-dark); }
.plan-price-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--violet);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 3px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.plan-price-label { font-weight: 800; color: var(--text-soft); font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; }
.plan-price-value { font-size: 30px; font-weight: 900; margin: 6px 0 2px; }
.plan-price-value span { font-size: 18px; }
.plan-price-sub { font-size: 12px; font-weight: 700; color: var(--text-soft); margin-bottom: 14px; }
.plan-price-card .btn { margin-top: auto; width: 100%; }

/* tabela comparativa */
.plans-table { border-radius: 18px; overflow: hidden; border: 2px solid var(--line); }
.plans-table-head, .plans-table-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr;
  align-items: center;
}
.plans-table-head {
  background: var(--bg-soft);
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-soft);
  padding: 10px 14px;
  text-align: center;
}
.plans-table-head div:first-child { text-align: left; }
.plans-table-row {
  padding: 12px 14px;
  font-size: 13.5px;
  font-weight: 700;
  text-align: center;
  border-top: 1px solid var(--line);
}
.plans-table-row:nth-child(odd) { background: var(--bg-soft); }
.plans-table-feature { text-align: left; color: var(--text); }
.pc-yes { color: var(--primary-deep); font-size: 17px; font-weight: 900; }
.pc-no { color: var(--muted); }
.pc-val { color: var(--violet-dark); }

@media (max-width: 640px) {
  .plans-table-head, .plans-table-row { grid-template-columns: 1.4fr 0.8fr 0.8fr; font-size: 12px; }
}

/* ---------- Meu Perfil: hub gamificado ---------- */

/* hero: identidade (avatar com anel de XP) + estatísticas rápidas */
.profile-hero {
  position: relative;
  background: linear-gradient(135deg, #e9fefa, var(--primary-soft) 45%, #f4f0ff);
  border-radius: 26px;
  padding: 26px 28px 22px;
  margin-bottom: 22px;
  overflow: hidden;
}
.profile-hero::before {
  /* brilho decorativo no canto, bem sutil */
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.14), transparent 70%);
  pointer-events: none;
}
.ph-top { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.ph-avatar-wrap { position: relative; flex: 0 0 auto; }
/* anel de progresso de XP ao redor do avatar (conic-gradient controlado
   por --ph-pct em %) */
.ph-ring {
  --ph-pct: 0;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  padding: 7px;
  background: conic-gradient(var(--violet) calc(var(--ph-pct) * 1%), rgba(139, 92, 246, 0.18) 0);
}
.ph-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
  display: flex;
  /* o SVG do avatar é retrato (1 : 1.2): alinha pelo topo para o corte
     circular comer o corpo embaixo, nunca a cabeça/chapéu */
  align-items: flex-start;
  justify-content: center;
  line-height: 0;
  padding-top: 6px;
}
.ph-avatar-edit {
  position: absolute;
  top: 0;
  right: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #fff;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  transition: transform 0.12s;
}
.ph-avatar-edit:hover { transform: scale(1.1); }
.ph-level-chip {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--violet);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  padding: 3px 14px;
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--violet-dark);
  white-space: nowrap;
}
.ph-id { flex: 1; min-width: 220px; }
.ph-id h1 { margin-bottom: 6px; overflow-wrap: anywhere; }
.ph-badges { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ph-level-name { font-weight: 800; color: var(--primary-deep); font-size: 14px; }
.ph-streak-chip {
  background: var(--orange-soft);
  color: var(--orange-dark);
  font-weight: 900;
  font-size: 13px;
  padding: 3px 12px;
  border-radius: 999px;
}
.ph-xp { margin-top: 12px; max-width: 420px; }
.ph-xp-label {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-soft);
}
.ph-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 20px;
}
.ph-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 16px;
  padding: 10px 14px;
}
.ph-stat-emoji { font-size: 22px; }
.ph-stat-num { font-size: 18px; font-weight: 900; line-height: 1.1; }
.ph-stat-lab { font-size: 10px; font-weight: 800; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.5px; }

/* cards de submódulos: navegação principal do perfil */
.profile-modules {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.module-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 0 var(--line-strong);
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.module-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--line-strong);
  border-color: var(--mc-accent, var(--line));
}
.module-card:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line-strong); }
.mc-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: var(--mc-soft, var(--bg-soft));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.06);
}
.mc-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mc-name { font-weight: 900; font-size: 16px; color: var(--text); }
.mc-sub { font-size: 12.5px; font-weight: 700; color: var(--text-soft); }
.mc-badge {
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  border-radius: 999px;
  padding: 2px 9px;
  margin-left: auto;
  flex-shrink: 0;
}
.mc-badge[hidden] { display: none; }
.mc-arrow { margin-left: auto; color: var(--muted); font-size: 24px; font-weight: 900; line-height: 1; }
.mc-badge:not([hidden]) + .mc-arrow { margin-left: 8px; }
/* acento por módulo (fundo do ícone + borda no hover) */
.mc-cyan   { --mc-soft: var(--primary-soft); --mc-accent: var(--primary-dark); }
.mc-blue   { --mc-soft: var(--blue-soft);    --mc-accent: var(--blue); }
.mc-yellow { --mc-soft: var(--yellow-soft);  --mc-accent: var(--yellow); }
.mc-violet { --mc-soft: var(--violet-soft);  --mc-accent: var(--violet); }
.mc-orange { --mc-soft: var(--orange-soft);  --mc-accent: var(--orange); }
.mc-gray   { --mc-soft: var(--bg-soft);      --mc-accent: var(--line-strong); }

@media (max-width: 600px) {
  .profile-hero { padding: 22px 18px 18px; }
  .ph-top { flex-direction: column; text-align: center; gap: 18px; }
  .ph-badges, .ph-xp-label { justify-content: center; text-align: center; }
  .ph-xp { margin-left: auto; margin-right: auto; }
  .ph-stats { grid-template-columns: repeat(2, 1fr); margin-top: 16px; }
  .profile-modules { grid-template-columns: 1fr; }
}

.avatar-svg { display: block; }

/* idle: respiração e piscar sutis, contínuos, pra nunca parecer estático */
.avatar-state-idle .avatar-body {
  animation: avatar-breathe 3.2s ease-in-out infinite;
  transform-origin: 100px 240px;
}
.avatar-state-idle .avatar-eye-l,
.avatar-state-idle .avatar-eye-r {
  animation: avatar-blink 5s ease-in-out infinite;
}
/* os braços respiram junto com o tronco pra não descolarem do ombro
   enquanto o corpo escala */
.avatar-state-idle .avatar-arms {
  animation: avatar-breathe 3.2s ease-in-out infinite;
  transform-origin: 100px 240px;
}

/* a boca é renderizada com 3 variantes empilhadas (base escolhida pelo
   usuário + feliz + triste ocultas); os estados só alternam a visível —
   funciona com bocas preenchidas, sem depender de morphing de path */
.avatar-mouth-happy, .avatar-mouth-sad { opacity: 0; }

/* feliz: braços erguem em V (antecipação → sobe com overshoot → segura no
   alto com um "pump" → desce), sorriso abre, corpo dá um pulinho; o pulo é
   aplicado igual no grupo dos braços pra eles acompanharem o tronco */
.avatar-state-happy .avatar-arm-l { animation: avatar-happy-arm-l 1.8s ease-in-out; }
.avatar-state-happy .avatar-arm-r { animation: avatar-happy-arm-r 1.8s ease-in-out; }
.avatar-state-happy .avatar-arm-l .avatar-forearm { animation: avatar-happy-forearm-l 1.8s ease-in-out; }
.avatar-state-happy .avatar-arm-r .avatar-forearm { animation: avatar-happy-forearm-r 1.8s ease-in-out; }
.avatar-state-happy .avatar-arms { animation: avatar-happy-bounce 0.9s ease-in-out 2; transform-origin: 100px 240px; }
.avatar-state-happy .avatar-mouth-base { opacity: 0; }
.avatar-state-happy .avatar-mouth-happy { opacity: 1; animation: avatar-happy-pop 0.35s ease-out; transform-origin: 100px 108px; }
.avatar-state-happy .avatar-body { animation: avatar-happy-bounce 0.9s ease-in-out 2; transform-origin: 100px 240px; }

/* triste: boca vira, lágrima escorre, cabeça baixa */
.avatar-state-sad .avatar-mouth-base { opacity: 0; }
.avatar-state-sad .avatar-mouth-sad { opacity: 1; }
.avatar-state-sad .avatar-tear { animation: avatar-sad-tear 1.4s ease-in forwards; }
.avatar-state-sad .avatar-head { animation: avatar-sad-droop 1.4s ease-in-out forwards; }

@keyframes avatar-breathe {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.02); }
}
@keyframes avatar-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.1); }
}
/* pose de comemoração em dois pivôs: o ombro leva o braço até ~122° (cotovelo
   pra fora, na altura do queixo, longe do rosto) e o cotovelo dobra ~+50° no
   mesmo ritmo, deixando o antebraço vertical — o punho para AO LADO da
   cabeça, com folga (dobrar mais que isso manda a mão pra trás da cabeça) */
@keyframes avatar-happy-arm-l {
  0%   { transform: rotate(0deg); }
  9%   { transform: rotate(-12deg); }  /* antecipação: recua antes de subir */
  28%  { transform: rotate(131deg); }  /* sobe passando do ponto (overshoot) */
  38%  { transform: rotate(121deg); }  /* acomoda */
  52%  { transform: rotate(127deg); }  /* "pump" de comemoração */
  64%  { transform: rotate(122deg); }
  80%  { transform: rotate(122deg); }  /* segura no alto */
  100% { transform: rotate(0deg); }    /* desce suave de volta ao repouso */
}
@keyframes avatar-happy-arm-r {
  0%   { transform: rotate(0deg); }
  9%   { transform: rotate(12deg); }
  28%  { transform: rotate(-131deg); }
  38%  { transform: rotate(-121deg); }
  52%  { transform: rotate(-127deg); }
  64%  { transform: rotate(-122deg); }
  80%  { transform: rotate(-122deg); }
  100% { transform: rotate(0deg); }
}
@keyframes avatar-happy-forearm-l {
  0%   { transform: rotate(0deg); }
  9%   { transform: rotate(6deg); }    /* cotovelo "engatilha" na antecipação */
  28%  { transform: rotate(58deg); }
  38%  { transform: rotate(48deg); }
  52%  { transform: rotate(54deg); }
  64%  { transform: rotate(50deg); }
  80%  { transform: rotate(50deg); }
  100% { transform: rotate(0deg); }
}
@keyframes avatar-happy-forearm-r {
  0%   { transform: rotate(0deg); }
  9%   { transform: rotate(-6deg); }
  28%  { transform: rotate(-58deg); }
  38%  { transform: rotate(-48deg); }
  52%  { transform: rotate(-54deg); }
  64%  { transform: rotate(-50deg); }
  80%  { transform: rotate(-50deg); }
  100% { transform: rotate(0deg); }
}
@keyframes avatar-happy-pop {
  0% { transform: scale(0.4); }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes avatar-happy-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes avatar-sad-tear {
  0% { opacity: 0; transform: translateY(0); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateY(18px); }
}
@keyframes avatar-sad-droop {
  to { transform: rotate(4deg); }
}

/* ---------- criador de avatar ---------- */

.avatar-creator-screen {
  position: fixed;
  inset: 0;
  height: 100svh;
  background: #fff;
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 100vw;
}
.avatar-creator-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  padding-top: calc(18px + env(safe-area-inset-top));
  flex: 0 0 auto;
}
.avatar-creator-title { font-size: 20px; font-weight: 900; }
.avatar-creator-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 24px 24px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}
.avatar-creator-preview {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 0 16px;
  background: var(--bg);
  box-shadow: 0 8px 12px -8px rgba(0, 0, 0, 0.15);
}
.avatar-creator-foot {
  flex: 0 0 auto;
  padding: 16px 24px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  gap: 16px;
}
.avatar-creator-foot .btn { min-width: 220px; }

.avatar-panel { margin-bottom: 22px; }
.avatar-panel-label { font-weight: 800; margin-bottom: 8px; color: var(--text-soft); }
.avatar-swatch-row { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-swatch {
  border: 3px solid var(--line);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  padding: 0;
}
.avatar-swatch.selected { border-color: var(--violet); box-shadow: 0 0 0 2px var(--violet-soft); }
.avatar-swatch-label {
  border-radius: 12px;
  width: auto;
  height: auto;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  background: var(--bg-soft);
  color: var(--text);
}

@media (max-width: 760px) {
  .avatar-creator-top { padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top)); }
  .avatar-creator-body { padding: 0 16px 16px; }
}

/* ============================================================
   Amigos, Grupos, Chat e Ofensiva
   ============================================================ */

/* Friends page (redesign: consistente com o hub do perfil) */
.friends-container { padding: 0 0 24px; }
.friends-section { margin: 26px 0; }
.friends-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 900;
  margin-bottom: 12px;
  color: var(--text);
}
.count-chip {
  background: var(--violet-soft);
  color: var(--violet-dark);
  font-size: 12px;
  font-weight: 900;
  padding: 2px 10px;
  border-radius: 999px;
}
.count-chip.red { background: var(--red); color: #fff; }

/* pedidos recebidos: destaque no topo da tela */
.requests-highlight {
  background: var(--violet-soft);
  border-radius: 18px;
  padding: 16px 18px;
  margin-top: 18px;
}
.requests-highlight .friends-section-title { margin-bottom: 10px; }

/* card-convite */
.friends-invite-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(120deg, #e9fefa, var(--primary-soft) 70%);
}
.fic-emoji { font-size: 30px; }
.fic-body { flex: 1; min-width: 0; }
.fic-title { font-weight: 900; font-size: 15px; }
.fic-sub { font-size: 12.5px; font-weight: 700; color: var(--primary-deep); }
.invite-link-result { margin-top: 10px; }
.invite-link-input {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  font-size: 13px;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  margin-bottom: 8px;
}
.invite-link-actions { display: flex; gap: 8px; }

/* lista de amigos */
.friends-list { display: flex; flex-direction: column; gap: 10px; }
.friend-card {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 3px 0 var(--line-strong);
}
.friend-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--primary-soft);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.avatar-placeholder { width: 100%; height: 100%; background: var(--bg-soft); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.avatar-placeholder-sm { width: 36px; height: 36px; background: var(--bg-soft); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.friend-info { flex: 1; min-width: 0; }
.friend-name { font-weight: 900; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend-streak { margin-top: 3px; }
.friend-streak[role="button"] { cursor: pointer; }
.friend-actions { flex-shrink: 0; display: flex; gap: 6px; align-items: center; }

/* chips de status da ofensiva no card do amigo */
.fs-chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 999px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fs-none   { background: var(--bg-soft); color: var(--muted); }
.fs-wait   { background: var(--yellow-soft); color: #8a6d00; }
.fs-invite { background: var(--orange-soft); color: var(--orange-dark); }
.fs-active { background: var(--orange-soft); color: var(--orange-dark); }
.friend-streak[role="button"] .fs-active:hover { filter: brightness(0.96); text-decoration: underline; }

/* grade de grupos: mesmos cards 3D do hub do perfil */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.group-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 4px 0 var(--line-strong);
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.group-card:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--line-strong); border-color: var(--violet); }
.group-card:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line-strong); }
.gc-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--violet-soft);
}
.gc-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.gc-name { font-weight: 900; font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gc-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; font-weight: 700; color: var(--text-soft); }
.gc-streak { color: var(--orange-dark); font-weight: 900; }
.gc-arrow { color: var(--muted); font-size: 22px; font-weight: 900; line-height: 1; }
.group-card-new { border-style: dashed; box-shadow: none; background: var(--bg-soft); }
.group-card-new:hover { border-color: var(--primary-dark); box-shadow: none; }
.group-card-new .gc-icon { background: var(--primary-soft); }

/* solicitações */
.requests-list { display: flex; flex-direction: column; gap: 8px; }
.request-card {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.request-sent { opacity: 0.75; }
.request-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--primary-soft);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.request-info { flex: 1; min-width: 0; }
.request-name { font-weight: 900; font-size: 14px; }
.request-status { font-size: 12px; font-weight: 700; color: var(--text-soft); }
.request-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* variação menor do botão-ícone (usada nas ações do card de amigo) */
.icon-btn-sm { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn-sm .icon { width: 15px; height: 15px; }

/* Group detail */
.group-detail { padding: 0 0 24px; }
.group-header { margin-bottom: 20px; }
.btn-back { margin-bottom: 8px; font-size: 14px; }
.group-title { font-size: 22px; font-weight: 900; margin-bottom: 4px; }
.group-description { font-size: 14px; color: var(--text-muted); }

/* Group streak card */
.group-streak-card {
  background: linear-gradient(135deg, var(--primary-soft), #eafffb);
  border: 2px solid var(--primary);
  border-radius: 18px;
  padding: 20px;
  color: var(--primary-ink);
  margin-bottom: 16px;
  text-align: center;
}
.group-streak-card.streak-complete {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: var(--primary-dark);
}
.streak-header { margin-bottom: 8px; }
.streak-fire { font-size: 32px; }
.streak-count { font-size: 28px; font-weight: 900; margin-left: 8px; }
.streak-goal { font-size: 14px; opacity: 0.85; margin-bottom: 12px; }
.streak-status { font-size: 15px; font-weight: 700; margin-bottom: 16px; padding: 8px; border-radius: 10px; }
.status-done { background: rgba(6,95,70,0.12); color: #065f46; }
.status-waiting { background: rgba(180,83,9,0.14); color: #b45309; }
.streak-members-progress { text-align: left; margin-bottom: 12px; }
.streak-member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 14px;
}
.streak-member-status { font-size: 16px; }
.streak-member-status.member-done { color: var(--primary-deep); }
.streak-member-status.member-pending { color: var(--red-dark); opacity: 0.75; }
.streak-member-name { flex: 1; }
.streak-member-xp { font-weight: 700; font-size: 13px; }
.streak-best { font-size: 12px; opacity: 0.75; }

/* Group actions bar */
.group-actions-bar { display: flex; gap: 8px; margin-bottom: 20px; }

/* Group chat */
.group-chat-section { margin-bottom: 24px; }
.group-chat-section h3 { font-size: 16px; font-weight: 800; margin-bottom: 12px; }
.chat-container {
  background: var(--bg-soft);
  border-radius: 16px;
  padding: 12px;
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.chat-msg {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: flex-start;
}
.chat-msg-own { flex-direction: row-reverse; }
.chat-msg-body {
  max-width: 75%;
  background: var(--bg);
  border-radius: 14px;
  padding: 10px 14px;
  position: relative;
}
.chat-msg-own .chat-msg-body { background: var(--violet-soft); }
.chat-msg-sender { font-size: 12px; font-weight: 700; color: var(--violet); margin-bottom: 4px; }
.chat-msg-content { font-size: 14px; word-break: break-word; }
.chat-msg-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-align: right; }
.chat-msg-react-btn {
  opacity: 0;
  cursor: pointer;
  color: var(--text-muted);
  transition: opacity 0.15s;
  padding: 4px;
}
.chat-msg:hover .chat-msg-react-btn { opacity: 1; }
.msg-reactions { display: flex; gap: 4px; margin-top: 4px; }
.reaction-badge {
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 14px;
}

/* Reaction picker */
.reaction-picker {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 8px;
  display: flex;
  gap: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 10;
}
.reaction-option {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: background 0.15s;
}
.reaction-option:hover { background: var(--bg-soft); }

/* Chat input */
.chat-input-bar {
  display: flex;
  gap: 8px;
}
.chat-input-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

/* Members list */
.group-members-section { margin-bottom: 24px; }
.group-members-section h3 { font-size: 16px; font-weight: 800; margin-bottom: 12px; }
.members-list { display: flex; flex-direction: column; gap: 8px; }
.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.member-avatar { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.member-info { flex: 1; min-width: 0; }
.member-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.member-name { font-weight: 700; font-size: 14px; }
.admin-badge {
  background: var(--violet-soft);
  color: var(--violet);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 4px;
}
.member-streak { font-size: 12px; color: var(--text-muted); }

/* Leave group */
.group-leave-section { text-align: center; padding-top: 16px; }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: rgba(239,68,68,0.1); }

/* Invite page */
.invite-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 20px;
}
.invite-card {
  background: var(--bg);
  border-radius: 24px;
  padding: 32px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.invite-icon { font-size: 48px; margin-bottom: 16px; }
.invite-title { font-size: 22px; font-weight: 900; margin-bottom: 12px; }
.invite-avatar { margin: 16px auto; }
.invite-avatar-placeholder {
  width: 80px;
  height: 80px;
  margin: 16px auto;
  border-radius: 50%;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
}
.btn-lg { padding: 14px 26px; font-size: 17px; }
.group-detail-error { text-align: center; padding: 48px 20px; }
.group-detail-error p { font-weight: 700; color: var(--text-soft); margin-bottom: 16px; }
.invite-description { font-size: 15px; margin-bottom: 8px; }
.invite-subdescription { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.invite-group-info { margin: 16px 0; }
.invite-group-name { font-size: 18px; font-weight: 800; }
.invite-group-desc { font-size: 13px; color: var(--text-muted); }
.invite-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }

/* Streak widget (home) */
.streak-widget {
  background: linear-gradient(135deg, var(--primary-soft), #eafffb);
  border: 2px solid var(--primary);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
  color: var(--primary-ink);
}
.streak-widget-title { font-size: 16px; font-weight: 800; margin-bottom: 12px; }
.streak-widget-item {
  background: rgba(255,255,255,0.55);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
}
.streak-widget-item:last-child { margin-bottom: 0; }
.streak-widget-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.streak-widget-fire { font-size: 20px; }
.streak-widget-count { font-size: 18px; font-weight: 900; }
.streak-widget-info { font-size: 13px; opacity: 0.85; margin-bottom: 8px; }
.streak-widget-progress { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.streak-check { color: #065f46; }
.streak-pending { color: #b45309; }
.streak-widget-status { font-size: 13px; font-weight: 700; }
.streak-all-done { color: #065f46; }
.streak-waiting { color: #b45309; }

/* Streak list */
.streak-list { display: flex; flex-direction: column; gap: 8px; }
.streak-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.streak-list-item:hover { border-color: var(--violet); }
.streak-list-avatar { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; flex-shrink: 0; }
.streak-list-icon { font-size: 24px; flex-shrink: 0; }
.streak-list-info { flex: 1; min-width: 0; }
.streak-list-name { font-weight: 700; font-size: 14px; }
.streak-list-meta { font-size: 12px; color: var(--text-muted); }
.streak-list-arrow { color: var(--text-muted); font-size: 16px; }

/* Buttons */
.btn-whatsapp { background: #25d366; color: #fff; }
.btn-whatsapp:hover { background: #1da851; }
.btn-fire { background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; }
.btn-fire:hover { opacity: 0.9; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 8px; }

/* Loading */
.friends-loading, .group-detail-loading {
  text-align: center;
  padding: 40px;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--violet);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error state */
.error-state {
  text-align: center;
  padding: 40px;
  color: var(--red);
}

/* Chat avatar mini */
.chat-avatar-mini {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

/* Mobile */
@media (max-width: 760px) {
  .invite-card { padding: 24px 20px; }
  .group-streak-card { padding: 16px; }
  .streak-count { font-size: 22px; }
  .chat-container { max-height: 300px; }
}
