/* =========================================================
   WeWeKa · Estilos
   Paleta: beige + naranja, cálida y artesanal (no futurista)
   Tipografía: Segoe UI · 12px min / 16px max
   ========================================================= */

:root {
  --bg: #f5eddf;
  --bg2: #efe3cd;
  --card: #fffbf2;
  --ink: #4a3626;
  --muted: #94795f;
  --line: #e7d9c0;
  --orange: #e0762f;
  --orange-deep: #b95a1e;
  --orange-soft: #f7ddc2;
  --green: #7c9457;
  --green-deep: #5f7442;
  --green-soft: #e9efdd;
  --blue: #5a7fb5;
  --blue-deep: #3f5f8f;
  --blue-soft: #e3ecf7;
  --red: #c05b48;
  --red-soft: #f6e0da;
  --shadow: 0 2px 10px rgba(122, 82, 40, .10);
  --r: 18px;
}

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

html, body { height: 100%; }

body {
  font-family: "Segoe UI", "Segoe UI Emoji", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, #f9f1e2 0%, transparent 45%),
    var(--bg);
  overscroll-behavior: none;
}

button {
  font-family: inherit;
  font-size: 14px;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
button:disabled { cursor: default; }

/* ---------- Estructura ---------- */
.app {
  max-width: 460px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}
.screen {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}
.wrap { padding: 16px 16px 24px; }

.fadein { animation: fadein .35s ease both; }
@keyframes fadein {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Navegación inferior ---------- */
.bottomnav {
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(122, 82, 40, .08);
}
.navbtn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  color: var(--muted);
  border-radius: 14px;
  transition: color .2s, background .2s;
}
.navbtn svg { width: 26px; height: 26px; }
.navbtn span { font-size: 12px; }
.navbtn.active { color: var(--orange-deep); background: var(--orange-soft); }

/* ---------- Cabecera ---------- */
.apphead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}
.logo b { letter-spacing: .04em; color: var(--orange-deep); }

.iconbtn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: var(--shadow);
  flex: none;
}
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn:active { transform: scale(.94); }

.lead {
  font-size: 14px;
  color: var(--muted);
  margin: 4px 2px 16px;
}

/* ---------- Selección de lengua ---------- */
.langgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.langcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s;
}
.langcard:active { transform: scale(.96); border-color: var(--orange); }

/* Sección "lenguas": tarjetas translúcidas estilo vidrio verde claro */
.langgrid-glass .langcard {
  background: linear-gradient(160deg, rgba(233, 239, 221, .55), rgba(124, 148, 87, .18));
  border: 1px solid rgba(124, 148, 87, .35);
  box-shadow: 0 4px 18px rgba(95, 116, 66, .14), inset 0 1px 0 rgba(255, 255, 255, .45);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.langgrid-glass .langcard:active { border-color: var(--green-deep); }
.langic { font-size: 40px; line-height: 1.2; }
/* Icono ilustrado de cada lengua: hereda el tamaño del contenedor (1em ≈ el
   tamaño del emoji al que sustituye); el radio recorta el fondo blanco de
   las esquinas de la placa */
.langimg {
  width: 1.2em;
  height: 1.2em;
  object-fit: cover;
  display: inline-block;
  vertical-align: -0.25em;
  border-radius: 22%;
}
.langname { font-size: 16px; font-weight: 700; }
.langendo { font-size: 12px; color: var(--orange-deep); font-style: italic; }
.langmeta { font-size: 12px; color: var(--muted); }

.langbar {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg2);
  overflow: hidden;
  margin: 6px 0 2px;
  display: block;
}
.langbar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--orange-deep));
  border-radius: 3px;
  transition: width .4s ease;
}

/* ---------- Modal ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 54, 38, .45);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
  animation: fadein .2s ease both;
}
.modal {
  background: var(--card);
  border-radius: 22px;
  padding: 24px 20px;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 12px 40px rgba(74, 54, 38, .3);
}
.modalic { font-size: 44px; }
.modal h2 { font-size: 16px; }
.modal p { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ---------- Botones ---------- */
.btn {
  border-radius: 14px;
  padding: 14px 20px;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .01em;
  transition: transform .12s, filter .15s, box-shadow .12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(180deg, var(--orange), var(--orange-deep));
  color: #fff;
  box-shadow: 0 4px 0 #96491a;
}
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 #96491a; translate: 0 3px; }
.btn.primary:disabled { filter: grayscale(.6) opacity(.55); box-shadow: none; }
.btn.warn { background: var(--ink); color: #fff; box-shadow: 0 4px 0 #2c1f12; }
.btn.ghost { background: var(--bg2); color: var(--muted); margin-top: 16px; width: 100%; }
.btn.danger { background: var(--red); color: #fff; }
.btn.big { width: 100%; padding: 15px; }

/* ---------- Camino (hero + niveles) ---------- */
.hero {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 8px;
  z-index: 10;
}
.heroic { font-size: 32px; }
.herotxt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.herotxt b { font-size: 15px; }
.herotxt > span:not(.langbar) {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.herostats { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; }

.levelsec { margin-top: 22px; }
.levelhead {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, var(--orange-soft), transparent 80%);
  border-radius: 14px;
  padding: 10px 12px;
}
.levelhead .lvlic { font-size: 26px; }
.levelhead b { font-size: 15px; display: block; }
.levelhead span:not(.lvlic):not(.lock) { font-size: 12px; color: var(--orange-deep); }
.levelhead .lock { margin-left: auto; font-size: 16px; }
.levelhead.locked { filter: grayscale(1) opacity(.6); }
.leveldesc { font-size: 12px; color: var(--muted); margin: 6px 4px 4px 14px; }
.leveldesc.locked { opacity: .55; }

.path {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px 6px;
  padding: 14px 0 4px;
  justify-items: center;
}
.node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}
/* En rejilla de 4 columnas se ignoran los desplazamientos del zigzag antiguo */
.node.s0, .node.s1, .node.s2 { align-self: auto; margin: 0; }
.nodeic {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  font-size: 30px;
  border-radius: 50%;
  background: var(--card);
  border: 3px solid var(--line);
  box-shadow: 0 4px 0 var(--line);
  transition: transform .15s;
}
.node:active:not(:disabled) .nodeic { transform: scale(.93); }
.node.done .nodeic {
  background: linear-gradient(180deg, var(--orange), var(--orange-deep));
  border-color: var(--orange-deep);
  box-shadow: 0 4px 0 #96491a;
}
.node.now .nodeic {
  border-color: var(--orange);
  animation: pulse 1.6s ease infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 0 var(--line), 0 0 0 0 rgba(224, 118, 47, .45); }
  50% { box-shadow: 0 4px 0 var(--line), 0 0 0 12px rgba(224, 118, 47, 0); }
}
.node.todo { opacity: .55; }
.nodelbl { font-size: 12px; color: var(--muted); text-align: center; }
.node.now .nodelbl { color: var(--orange-deep); font-weight: 700; }

.alldone {
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  margin-top: 20px;
  box-shadow: var(--shadow);
}
.alldone span { font-size: 44px; display: block; }
.alldone b { font-size: 16px; }
.alldone p { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ---------- Inicio ---------- */
.homecard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

/* Insignia mensual */
.badgetop { display: flex; align-items: center; gap: 14px; }
.badgeic {
  width: 74px;
  height: 74px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 42px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--orange-soft), #fff3e3);
  border: 3px solid var(--orange);
  box-shadow: 0 4px 0 var(--orange-deep);
}
.badgetxt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.badgetxt b { font-size: 15px; }
.badgetxt > span:not(.langbar) { font-size: 12px; color: var(--muted); }
.badgetxt .badgemeta { color: var(--orange-deep); font-weight: 600; }
.badgegrid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.badge { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.badge i {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 24px;
  border-radius: 50%;
  background: var(--orange-soft);
  border: 2px solid var(--orange);
}
.badge em { font-style: normal; font-size: 10px; color: var(--muted); text-align: center; }
.badge.locked i {
  font-size: 15px;
  background: var(--bg2);
  border-color: var(--line);
  filter: grayscale(1);
  opacity: .75;
}
.badge.locked em { opacity: .6; }

/* Ranking */
.ranklist { padding: 8px 10px; }
.rankrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 6px;
  border-bottom: 1px dashed var(--line);
}
.rankrow:last-child { border-bottom: none; }
.rankpos { width: 26px; flex: none; text-align: center; font-weight: 700; font-size: 14px; color: var(--muted); }
.rankname {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ranklangs { font-size: 15px; letter-spacing: 1px; flex: none; }
.rankpts { font-size: 13px; color: var(--orange-deep); flex: none; }
.rankrow.me {
  background: var(--orange-soft);
  border-radius: 12px;
  border-bottom-color: transparent;
  padding: 9px 8px;
}
.rankrow.me .rankname { color: var(--orange-deep); font-weight: 700; }

/* Recordatorio diario */
.todayrow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}
.todayic { font-size: 34px; flex: none; }
.todaytxt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.todaytxt b { font-size: 14px; }
.todaytxt span { font-size: 12px; color: var(--muted); }
.todayrow .btn { padding: 10px 16px; font-size: 14px; flex: none; }

.remindrow { display: flex; align-items: center; gap: 10px; }
.remindlbl { flex: 1; font-size: 13px; color: var(--muted); }
.switch {
  width: 52px;
  height: 30px;
  flex: none;
  position: relative;
  border-radius: 999px;
  background: var(--bg2);
  border: 2px solid var(--line);
  transition: background .2s, border-color .2s;
}
.switch i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(74, 54, 38, .3);
  transition: left .2s;
}
.switch.on { background: var(--orange); border-color: var(--orange-deep); }
.switch.on i { left: 24px; }
.timein {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 7px 10px;
  flex: none;
}
.timein:disabled { opacity: .5; }
.remindstatus { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 10px; }

/* ---------- Traductor de voz ---------- */
.talk { height: 100%; display: flex; flex-direction: column; }
.talkhead {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.talklogo { flex: none; font-size: 26px; line-height: 1; display: flex; }
.talklogo .langimg { width: 30px; height: 30px; }
.talkheadr { flex: none; display: flex; align-items: center; gap: 4px; }

/* selector de lengua (menú desplegable superior) */
.langpick {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.langsel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: none;
  cursor: pointer;
  font: inherit;
}
.langsel-label { font-size: 15px; font-weight: 700; color: var(--ink); }
.langsel-chev { display: flex; color: var(--muted); }
.langsel-chev svg { width: 16px; height: 16px; }

.talkmsgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.talkhint {
  background: var(--orange-soft);
  border: 1px dashed var(--orange);
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
}
.talknote { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 14px; }
.loadolder {
  align-self: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
}

.msg { display: flex; }
.msg.a { justify-content: flex-end; }
.msgbubble {
  max-width: 86%;
  color: var(--green-deep);
  background: var(--green-soft);
  border: 1px solid #d3ddc1;
  border-radius: 18px 18px 18px 6px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.msg.a .msgbubble {
  color: var(--blue-deep);
  background: var(--blue-soft);
  border-color: #cdddf0;
  border-radius: 18px 18px 6px 18px;
}

/* fila de audio: botón play/pausa + forma de onda que se llena */
.audiorow { display: flex; align-items: center; gap: 10px; }
.playbtn {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(180deg, var(--green), var(--green-deep));
  box-shadow: 0 2px 6px rgba(95, 116, 66, .4);
  transition: transform .12s;
}
.msg.a .playbtn { background: linear-gradient(180deg, var(--blue), var(--blue-deep)); box-shadow: 0 2px 6px rgba(63, 95, 143, .4); }
.playbtn:active { transform: scale(.92); }
.playbtn svg { width: 20px; height: 20px; }
.wave {
  position: relative;
  flex: 1;
  min-width: 90px;
  height: 34px;
}
.wave-base, .wave-fill {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 2px;
}
.wave-base span, .wave-fill span {
  flex: 1;
  min-height: 8%;
  border-radius: 2px;
  background: currentColor;
}
.wave-base { opacity: .32; }
.wave-fill { opacity: 1; clip-path: inset(0 100% 0 0); }
.wave.on .wave-base span { animation: wavepulse 1s ease-in-out infinite; }
@keyframes wavepulse { 0%, 100% { opacity: .5; } 50% { opacity: .85; } }

.msgmain { display: block; font-size: 15px; line-height: 1.4; color: var(--ink); margin-top: 8px; overflow-wrap: break-word; }
.msgsub { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; overflow-wrap: break-word; }
.msgnote { display: block; font-size: 11px; color: var(--red); margin-top: 3px; }
.unk { font-style: italic; opacity: .6; font-weight: 400; }
.msgmeta { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.msgmeta span { font-size: 10px; color: var(--muted); }

.talkbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 18px 14px;
  background: var(--card);
  border-top: 1px solid var(--line);
}
.miccell {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.micbtn {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  isolation: isolate;
  transition: transform .12s;
  --smoke: rgba(124, 148, 87, .55);
}
.micbtn.a { --smoke: rgba(90, 127, 181, .5); }
.micbtn:active { transform: scale(.94); }
.micbtn .micic {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: radial-gradient(circle at 38% 30%, #a7bd82, var(--green) 55%, var(--green-deep));
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, .4), 0 6px 14px rgba(95, 116, 66, .4);
}
.micbtn.a .micic {
  background: radial-gradient(circle at 38% 30%, #8fabd4, var(--blue) 55%, var(--blue-deep));
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, .4), 0 6px 14px rgba(63, 95, 143, .4);
}
.micbtn .micic svg { width: 28px; height: 28px; }
/* efecto de humo: wisps difuminados que ascienden en bucle */
.smoke {
  position: absolute;
  left: 50%;
  bottom: 44%;
  width: 26px;
  height: 26px;
  margin-left: -13px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--smoke) 0%, transparent 68%);
  filter: blur(7px);
  opacity: 0;
  z-index: -1;
  animation: smokeRise 3.4s ease-in-out infinite;
}
.smoke.s2 { animation-delay: 1.1s; animation-duration: 3.9s; --sx: -20px; }
.smoke.s3 { animation-delay: 2.2s; animation-duration: 3.2s; --sx: 22px; }
@keyframes smokeRise {
  0%   { opacity: 0; transform: translate(0, 8px) scale(.5); }
  25%  { opacity: .55; }
  60%  { opacity: .4; }
  100% { opacity: 0; transform: translate(var(--sx, 14px), -34px) scale(1.7); }
}
.miclbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  line-height: 1.2;
}
.miclbl i { display: block; font-style: normal; font-weight: 500; font-size: 10px; color: var(--muted); }
.midcol {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.langtoggle {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 3px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--blue-soft);
  border: 1px solid #a7c0de;
  color: var(--blue-deep);
}
.langtoggle b { font-size: 13px; font-weight: 800; letter-spacing: .04em; }
.langtoggle span { font-size: 10px; opacity: .55; }
.langtoggle.en { background: var(--green-soft); border-color: #bccca2; color: var(--green-deep); }
.kbbtn {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg2);
  border: 1px solid var(--line);
  font-size: 16px;
}
.msgsub.bridge { opacity: .85; }
.webtag { font-size: 12px; }
.webwait .msgmain::after {
  content: ' 🌐…';
  font-size: 12px;
  font-weight: 400;
  opacity: .55;
  animation: webpulse 1.2s ease infinite;
}
@keyframes webpulse {
  0%, 100% { opacity: .3; }
  50% { opacity: .8; }
}

/* grabación en vivo */
.recdot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--red);
  flex: none;
  animation: recpulse 1.1s ease infinite;
}
@keyframes recpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 91, 72, .5); }
  50% { box-shadow: 0 0 0 10px rgba(192, 91, 72, 0); }
}
.rectxt {
  flex: 1;
  min-height: 44px;
  max-height: 62px;
  overflow-y: auto;
  display: flex;
  align-items: center;
  font-size: 13px;
  font-style: italic;
  color: var(--muted);
}
.recstop {
  flex: none;
  padding: 11px 14px;
  border-radius: 14px;
  background: var(--red);
  color: #fff;
  font-weight: 700;
}
.reccancel {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--muted);
}

/* entrada por teclado (respaldo) */
.rolebtn {
  flex: none;
  font-size: 12px;
  font-weight: 700;
  padding: 9px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid var(--green);
}
.rolebtn.a { background: var(--orange-soft); color: var(--orange-deep); border-color: var(--orange); }
.txtin {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
}
.txtin:focus { outline: none; border-color: var(--orange); }
.sendbtn {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--orange), var(--orange-deep));
  color: #fff;
  font-size: 16px;
}

/* historial de conversaciones */
.headspace { width: 40px; flex: none; }
.histprev {
  display: block;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.histmeta {
  flex: none;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  line-height: 1.5;
}

/* aviso flotante */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 96px;
  z-index: 60;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  max-width: 86%;
  text-align: center;
  box-shadow: 0 6px 24px rgba(74, 54, 38, .35);
  animation: fadein .25s ease both;
}

/* ---------- Perfil ---------- */
.statrow { display: flex; gap: 10px; margin-bottom: 20px; }
.stat {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: var(--shadow);
}
.stat span { font-size: 24px; }
.stat b { font-size: 16px; }
.stat i { font-size: 12px; font-style: normal; color: var(--muted); }

.sectiontitle { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 4px 8px; }
.proglist { display: flex; flex-direction: column; gap: 8px; }
.progrow {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px;
  text-align: left;
  box-shadow: var(--shadow);
}
.progrow:active { transform: scale(.98); }
.progic { font-size: 28px; }
.progtxt { flex: 1; min-width: 0; }
.progtxt b { font-size: 14px; }
.progbadges { font-size: 13px; letter-spacing: 2px; color: var(--muted); }

/* ---------- Perfil · tarjeta de identidad ---------- */
.idtop { display: flex; gap: 16px; align-items: flex-start; }
.idleft { display: flex; flex-direction: column; align-items: center; gap: 10px; flex: none; }
.avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  flex: none;
  border: 3px solid var(--orange);
  box-shadow: 0 4px 0 var(--orange-deep);
  background: linear-gradient(180deg, var(--orange-soft), #fff3e3);
  display: grid;
  place-items: center;
  padding: 0;
}
.avatar:active { transform: scale(.97); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.empty span { font-size: 40px; }
.avatarcam {
  position: absolute;
  right: 2px;
  bottom: 2px;
  font-style: normal;
  font-size: 13px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
}
.photoacts { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.photoacts .chip {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  box-shadow: 0 2px 0 var(--line);
  transition: transform .12s, box-shadow .12s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.photoacts .chip:active { transform: translateY(2px); box-shadow: none; }
.photoacts .chip.danger { color: var(--red); border-color: #e3b7ab; box-shadow: 0 2px 0 #e3b7ab; }

.unamebox { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.unamelbl { font-size: 12px; font-weight: 700; color: var(--muted); }
.unamerow {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px 4px 4px 10px;
}
.unamein {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  padding: 8px 0;
  outline: none;
}
.unamesave {
  flex: none;
  width: auto;
  min-height: 40px;
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 10px;
  margin: 0;
}
.unamemsg { font-size: 12px; color: var(--muted); min-height: 16px; line-height: 1.4; }
.unamemsg.ok { color: var(--green-deep); font-weight: 600; }
.unamemsg.bad { color: var(--red); font-weight: 600; }

/* Insignias ganadas */
.emptynote { font-size: 13px; color: var(--muted); line-height: 1.5; text-align: center; padding: 6px 4px; }
.wonhead { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.wonhead b { font-size: 18px; color: var(--orange-deep); }
.wongrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 6px; }
.wonbadge { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wonbadge i {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 26px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--orange-soft), #fff3e3);
  border: 2px solid var(--orange);
  box-shadow: 0 3px 0 var(--orange-deep);
}
.wonbadge em { font-style: normal; font-size: 10px; color: var(--muted); text-align: center; line-height: 1.2; }
.wonbadge i .langimg { width: 34px; height: 34px; }
/* Lenguas aún no completadas: insignia en gris */
.wonbadge.locked i {
  background: linear-gradient(180deg, #e9e3d7, #ded6c6);
  border-color: #c9bda6;
  box-shadow: 0 3px 0 #b3a68d;
}
.wonbadge.locked i .langimg { filter: grayscale(1); opacity: .45; }

/* Racha máxima */
.streakcard { text-align: center; }
.streakbig { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.streakbig span { font-size: 30px; }
.streakbig b { font-size: 40px; color: var(--orange-deep); line-height: 1; }
.streakbig i { font-style: normal; font-size: 13px; color: var(--muted); }
.streaksub { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 8px; }
.streaksub b { color: var(--ink); }

/* Posición en el ranking */
.posbig { display: flex; align-items: center; gap: 14px; }
.posmedal {
  width: 62px;
  height: 62px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 800;
  color: var(--orange-deep);
  border-radius: 50%;
  background: linear-gradient(180deg, var(--orange-soft), #fff3e3);
  border: 3px solid var(--orange);
}
.postxt { display: flex; flex-direction: column; gap: 3px; }
.postxt b { font-size: 16px; }
.postxt span { font-size: 12px; color: var(--muted); }
.poscard .btn.ghost { margin-top: 12px; }

/* Editor de foto */
.photoeditor { gap: 12px; }
.pe-stage {
  width: 260px;
  height: 260px;
  max-width: 72vw;
  max-height: 72vw;
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: #000;
  touch-action: none;
  cursor: grab;
  align-self: center;
}
.pe-stage:active { cursor: grabbing; }
.pe-img { position: absolute; top: 0; left: 0; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.pe-mask {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .5);
  pointer-events: none;
}
.pe-zoom { display: flex; align-items: center; gap: 10px; width: 100%; }
.pe-zi { font-size: 16px; }
.pe-zoom input[type="range"] { flex: 1; accent-color: var(--orange); }

/* ---------- Lección ---------- */
.lesson {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
}
.lessonhead { display: flex; align-items: center; gap: 12px; }
.lessonic { font-size: 22px; }
.pbar {
  flex: 1;
  height: 12px;
  background: var(--bg2);
  border-radius: 6px;
  overflow: hidden;
}
.pbar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--orange), var(--orange-deep));
  transition: width .45s ease;
}
.lessonbody {
  flex: 1;
  overflow-y: auto;
  padding: 18px 2px 10px;
  display: flex;
  flex-direction: column;
}
.lessonfoot { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }

/* Flashcard */
.flash {
  margin: auto 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 34px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--orange-deep);
  background: var(--orange-soft);
  border-radius: 999px;
  padding: 4px 12px;
}
.flic { font-size: 72px; line-height: 1.15; }
.flash b { font-size: 16px; letter-spacing: .02em; }
.flash p { font-size: 14px; color: var(--muted); line-height: 1.5; max-width: 30ch; }

/* Ejercicio de opciones */
.exercise { display: flex; flex-direction: column; gap: 10px; margin: auto 0; }
.extitle { font-size: 16px; text-align: center; }
.exsub { font-size: 13px; color: var(--muted); text-align: center; }
.bigic { font-size: 60px; text-align: center; }

.npc { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 6px; }
.npcface { font-size: 34px; }
.bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 4px;
  padding: 12px 14px;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.opts { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 8px; }
.opts.iconic { grid-template-columns: 1fr 1fr; }
.opt {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 3px 0 var(--line);
  transition: transform .12s, border-color .15s, background .15s;
  justify-content: flex-start;
}
.opts.iconic .opt { justify-content: center; padding: 18px 10px; }
.opt .optic { font-size: 40px; line-height: 1.1; }
.opt .optic.sm { font-size: 24px; }
.opt:active:not(:disabled) { transform: scale(.97); }
.opt.sel { border-color: var(--orange); background: var(--orange-soft); box-shadow: 0 3px 0 var(--orange); }
.opt.right { border-color: var(--green); background: var(--green-soft); box-shadow: 0 3px 0 var(--green); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); box-shadow: 0 3px 0 var(--red); }

/* Parejas */
.matchgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.tile {
  min-height: 74px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  padding: 8px;
  box-shadow: 0 3px 0 var(--line);
  transition: opacity .25s, transform .12s;
}
.tile .optic { font-size: 36px; }
.tile.sel { border-color: var(--orange); background: var(--orange-soft); }
.tile.gone { opacity: .25; pointer-events: none; border-color: var(--green); }

.shake { animation: shake .35s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Secuencia TPR */
.seqrow { display: flex; justify-content: center; gap: 10px; margin: 6px 0; }
.seqslot {
  min-width: 64px;
  min-height: 64px;
  border-radius: 16px;
  background: var(--card);
  border: 2px dashed var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  padding: 4px;
  transition: all .25s;
}
.seqslot i { font-size: 12px; font-style: normal; color: var(--muted); }
.seqslot.on { border-style: solid; border-color: var(--orange); background: var(--orange-soft); transform: scale(1.06); }
.seqslot.ok { border-style: solid; border-color: var(--green); background: var(--green-soft); }
.seqpool { margin-top: 14px; }

/* Historia (inmersión) */
.story .storytxt {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px 16px;
  box-shadow: var(--shadow);
}
.storytxt p { font-size: 15px; line-height: 2; margin-bottom: 12px; }
.storytxt p:last-child { margin-bottom: 0; }
.chip {
  display: inline-block;
  background: var(--orange-soft);
  border: 1px dashed var(--orange);
  color: var(--orange-deep);
  font-weight: 700;
  font-size: 14px;
  border-radius: 999px;
  padding: 2px 10px;
  margin: 0 2px;
  transition: background .2s;
}
.chip.open { background: var(--green-soft); border-color: var(--green); color: var(--green); }

/* Hábitos (checklist) */
.habits { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.habit {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 2px 0 var(--line);
}
.habit span { font-size: 26px; }
.habit p { flex: 1; font-size: 13px; line-height: 1.4; }
.habit .tick {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-style: normal;
  color: transparent;
  flex: none;
}
.habit.on { border-color: var(--green); background: var(--green-soft); }
.habit.on .tick { background: var(--green); border-color: var(--green); color: #fff; }

/* ---------- Voz ---------- */
.speakbtn {
  width: 38px;
  height: 38px;
  flex: none;
  display: inline-grid;
  place-items: center;
  font-size: 17px;
  border-radius: 50%;
  background: var(--orange-soft);
  border: 1px solid var(--orange);
  box-shadow: var(--shadow);
  transition: transform .12s;
}
.speakbtn:active { transform: scale(.9); }
.flashword {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.extitlerow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.listenbtn {
  width: 96px;
  height: 96px;
  margin: 8px auto 0;
  display: grid;
  place-items: center;
  font-size: 42px;
  border-radius: 50%;
  background: var(--orange-soft);
  border: 3px solid var(--orange);
  box-shadow: 0 4px 0 var(--orange-deep);
  transition: transform .12s;
}
.listenbtn:active { transform: scale(.92); }

/* ---------- Speaking (di la respuesta al micrófono) ---------- */
.speaktag { text-align: center; }
.bigmic {
  width: 96px;
  height: 96px;
  margin: 8px auto 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--orange-soft);
  border: 3px solid var(--orange);
  box-shadow: 0 4px 0 var(--orange-deep);
  color: var(--orange-deep);
  transition: transform .12s, background .15s, border-color .15s;
}
.bigmic svg { width: 42px; height: 42px; }
.bigmic:active:not(:disabled) { transform: scale(.92); }
.bigmic:disabled { opacity: .45; }
.bigmic.rec {
  background: var(--red-soft);
  border-color: var(--red);
  box-shadow: 0 4px 0 var(--red);
  color: var(--red);
  animation: recpulse 1.1s ease infinite;
}
.speakstatus {
  min-height: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Construye la frase ---------- */
.buildprompt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 15px;
}
.buildprompt span { font-size: 26px; }
.buildprompt i { font-style: normal; font-weight: 600; }
.buildrow {
  min-height: 56px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 2px dashed var(--line);
  border-radius: 16px;
  background: var(--bg2);
}
.buildrow.right { border-color: var(--green); background: var(--green-soft); border-style: solid; }
.buildrow.wrong { border-color: var(--red); background: var(--red-soft); border-style: solid; }
.buildhint { font-size: 13px; font-style: normal; color: var(--muted); }
.buildpool {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}
.buildchip {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 3px 0 var(--line);
  transition: transform .12s;
}
.buildchip:active:not(:disabled) { transform: scale(.95); }
.buildchip.in { border-color: var(--orange); background: var(--orange-soft); box-shadow: 0 3px 0 var(--orange); }

/* Opción de solo texto (niveles altos, sin pista visual) */
.opt .optlbl { width: 100%; text-align: center; }

/* Feedback */
.feedback {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 16px;
  padding: 12px 14px;
  animation: fadein .25s ease both;
}
.feedback.ok { background: var(--green-soft); }
.feedback.bad { background: var(--red-soft); }
.feedback span { font-size: 28px; }
.feedback b { font-size: 14px; display: block; }
.feedback i { font-size: 13px; font-style: normal; color: var(--muted); }

/* Resultado */
.result {
  margin: auto 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.resic { font-size: 76px; animation: pop .5s ease both; }
@keyframes pop {
  0% { transform: scale(.3); opacity: 0; }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.result b { font-size: 16px; }
.result p { font-size: 13px; color: var(--muted); }
.resstats { display: flex; gap: 10px; width: 100%; }
.resstats > div {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow);
}
.resstats span { font-size: 22px; }
.resstats b { font-size: 16px; }
.resstats i { font-size: 12px; font-style: normal; color: var(--muted); }

/* Pantallas más anchas: la app se mantiene tipo teléfono, centrada */
@media (min-width: 520px) {
  .app {
    height: min(100dvh, 900px);
    margin: max(0px, calc((100dvh - 900px) / 2)) auto;
    border: 1px solid var(--line);
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(122, 82, 40, .18);
  }
}
