/* Kids-english-stories — estilo unificado (familia visual "parque de estampas").
   Optimizado para tabletas (iPad y Android), celulares y escritorio. */
@font-face { font-family: 'Fredoka'; src: url('assets/fonts/fredoka.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('assets/fonts/nunito.woff2') format('woff2'); font-weight: 200 1000; font-display: swap; }

:root {
  --primary: #E9553F;
  --primary-dark: #C33D29;
  --teal: #3CCFC0;
  --teal-dark: #259E92;
  --yellow: #FFC93C;
  --lilac: #C9A7F2;
  --lilac-dark: #8B5CF6;
  --mint: #9BE3B9;
  --bg: #FFF6EA;
  --card: #FFFFFF;
  --ink: #4A2617;
  --muted: #7C5A4B;
  --danger: #C62828;
  --radius: 22px;
  --shadow: 0 5px 0 rgba(74, 38, 23, 0.16);
  --border: 2.5px solid var(--ink);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 10%, rgba(255, 201, 60, 0.28) 0, transparent 32%),
    radial-gradient(circle at 88% 12%, rgba(60, 207, 192, 0.22) 0, transparent 35%),
    radial-gradient(circle at 82% 88%, rgba(201, 167, 242, 0.25) 0, transparent 36%);
  color: var(--ink);
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
h1, h2, h3, h4, .title { font-family: 'Fredoka', 'Nunito', sans-serif; margin: 0; line-height: 1.18; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }

/* Barra superior */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: rgba(255, 246, 234, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid rgba(74, 38, 23, 0.12);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; min-width: 0;
}
.brand-logo {
  width: 44px; height: 44px; border-radius: 14px;
  border: 2px solid var(--ink); background: #fff;
  object-fit: cover; flex: 0 0 auto;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text b {
  font-family: 'Fredoka', sans-serif; font-size: 1.12rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text small { font-size: 0.78rem; color: var(--muted); font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Contenedor principal */
main#app {
  max-width: 1060px;
  margin: 0 auto;
  padding: 20px 16px 96px;
}

/* Tarjetas */
.card {
  background: var(--card);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card.soft { background: #FFFBF4; }
.card.coral { background: linear-gradient(145deg, #FFF5F2 0%, #FFE4DC 100%); }
.card.teal { background: linear-gradient(145deg, #F0FFFD 0%, #D4F7F3 100%); }
.card.lilac { background: linear-gradient(145deg, #F8F3FF 0%, #EAE0FF 100%); }
.card.yellow { background: linear-gradient(145deg, #FFFDF2 0%, #FFF0BD 100%); }

/* Botones de juguete */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px;
  border: var(--border); border-radius: 16px;
  font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 1rem;
  cursor: pointer; text-decoration: none;
  background: #fff; color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease, filter .12s ease;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.teal { background: var(--teal); color: var(--ink); }
.btn.yellow { background: var(--yellow); color: var(--ink); }
.btn.lilac { background: var(--lilac); color: var(--ink); }
.btn.ghost { background: #FFFBF4; box-shadow: 0 3px 0 rgba(74, 38, 23, 0.25); }
.btn.danger { background: #FEE2E2; color: var(--danger); border-color: var(--danger); box-shadow: 0 3px 0 var(--danger); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 0.88rem; border-radius: 12px; box-shadow: 0 3px 0 var(--ink); }
.btn.xl { min-height: 58px; padding: 14px 26px; font-size: 1.2rem; border-radius: 20px; }
.btn.block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 42px; height: 42px; padding: 0 12px;
  border: 2px solid var(--ink); border-radius: 14px;
  background: #fff; cursor: pointer; font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 0.9rem;
  box-shadow: 0 3px 0 rgba(74, 38, 23, 0.25);
}
.icon-btn:active { transform: translateY(2px); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Etiquetas y pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 0.82rem; font-weight: 800;
  border: 2px solid var(--ink); background: #fff;
}
.pill.ok { background: var(--mint); }
.pill.warn { background: var(--yellow); }
.pill.lilac { background: var(--lilac); }
.pill.muted { border-color: rgba(74, 38, 23, 0.25); color: var(--muted); background: #FFFBF4; }

/* Hero infantil */
.kid-hero {
  display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center;
  margin-bottom: 20px;
}
.kid-hero-left { display: flex; align-items: center; gap: 16px; }
.mascot-hero { width: 96px; height: 96px; object-fit: contain; flex: 0 0 auto; }
.kid-greeting h1 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); margin-bottom: 6px; }
.kid-greeting p { margin: 0 0 12px; color: var(--muted); font-weight: 700; }
.kid-stats { display: flex; flex-wrap: wrap; gap: 8px; }

/* Tarjetas de niveles */
.levels-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}
.level-card {
  display: flex; flex-direction: column; gap: 14px;
  position: relative;
}
.level-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.level-badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 0.85rem;
  border: 2px solid var(--ink); background: var(--yellow);
}
.level-card.lvl2 .level-badge { background: var(--lilac); }
.level-card h2 { font-size: 1.45rem; margin-top: 6px; }
.level-card p { margin: 0; color: var(--muted); font-weight: 600; }
.prog-bar {
  height: 16px; border-radius: 999px; background: rgba(74, 38, 23, 0.1);
  border: 2px solid var(--ink); overflow: hidden;
}
.prog-fill {
  height: 100%; background: var(--teal);
  transition: width .35s ease;
}
.level-card.lvl2 .prog-fill { background: var(--lilac-dark); }
.prog-meta { display: flex; justify-content: space-between; font-size: 0.88rem; font-weight: 800; }
.quick-links { display: flex; flex-wrap: wrap; gap: 8px; }
.locked-banner {
  padding: 12px 14px; border-radius: 14px;
  background: rgba(74, 38, 23, 0.06); border: 2px dashed rgba(74, 38, 23, 0.3);
  font-weight: 700; color: var(--muted);
}

/* Selector de perfiles (tableta compartida / salón) */
.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.profile-tile {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 18px 14px; text-align: center; cursor: pointer;
  background: #fff; border: var(--border); border-radius: 22px;
  box-shadow: 0 5px 0 var(--ink); transition: transform .1s ease;
}
.profile-tile:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.profile-tile.active { background: #FFF0BD; }
.avatar-img {
  width: 78px; height: 78px; border-radius: 50%;
  border: 2.5px solid var(--ink); object-fit: cover; background: #FFF6EA;
}
.avatar-img.sm { width: 46px; height: 46px; border-width: 2px; }
.avatar-img.xs { width: 32px; height: 32px; border-width: 2px; }

/* Bienvenida / onboarding */
.welcome-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.welcome-card { display: flex; flex-direction: column; justify-content: space-between; gap: 14px; }
.welcome-card h2 { font-size: 1.25rem; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field span { font-weight: 800; font-size: 0.9rem; }
.field input, .field select {
  min-height: 46px; padding: 10px 14px;
  border: 2px solid var(--ink); border-radius: 14px;
  background: #fff; font-size: 1rem; font-weight: 600;
}
.field input:focus, .field select:focus { outline: 3px solid var(--yellow); }
.code-input {
  text-transform: uppercase; letter-spacing: 0.25em;
  font-family: 'Fredoka', monospace; font-size: 1.4rem !important; text-align: center;
}

.avatar-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.avatar-opt {
  padding: 4px; border: 2.5px solid transparent; border-radius: 50%;
  background: transparent; cursor: pointer;
}
.avatar-opt.selected { border-color: var(--primary); background: var(--yellow); }
.avatar-opt img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; display: block; }

/* Switch / toggle */
.switch {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 14px; background: #FFFBF4;
  border: 1.5px solid rgba(74, 38, 23, 0.16); cursor: pointer;
}
.switch input { width: 22px; height: 22px; accent-color: var(--primary); cursor: pointer; flex: 0 0 auto; }
.switch-txt { display: flex; flex-direction: column; }
.switch-txt b { font-size: 0.95rem; }
.switch-txt small { font-size: 0.8rem; color: var(--muted); }

/* Panel de adultos (Papás y Maestros) */
.panel-tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 16px 0 20px;
}
.panel-tab {
  min-height: 42px; padding: 8px 16px;
  border: 2px solid var(--ink); border-radius: 999px;
  background: #fff; font-family: 'Fredoka', sans-serif; font-weight: 600; cursor: pointer;
}
.panel-tab.active { background: var(--ink); color: #fff; }

.stats-row {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.stat-box {
  background: #fff; border: 2px solid var(--ink); border-radius: 16px;
  padding: 14px; text-align: center;
}
.stat-box b { display: block; font-family: 'Fredoka', sans-serif; font-size: 1.6rem; color: var(--primary); }
.stat-box small { font-weight: 800; color: var(--muted); font-size: 0.82rem; }

.children-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.child-card { display: flex; flex-direction: column; gap: 12px; }
.child-card-head { display: flex; align-items: center; gap: 12px; }
.child-card-head h3 { font-size: 1.2rem; }
.child-card-head small { color: var(--muted); font-weight: 700; display: block; }

.code-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 12px;
  background: var(--yellow); border: 2px solid var(--ink);
  font-family: 'Fredoka', monospace; font-size: 1.25rem; letter-spacing: 0.15em; font-weight: 700;
}

.day-list {
  list-style: none; padding: 0; margin: 10px 0 0;
  max-height: 260px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.day-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 12px;
  background: #FFFBF4; border: 1.5px solid rgba(74, 38, 23, 0.14);
  font-size: 0.88rem; font-weight: 700;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.mt-12 { margin-top: 12px; }
.mt-18 { margin-top: 18px; }
.muted { color: var(--muted); }
.error-msg { color: var(--danger); font-weight: 800; font-size: 0.9rem; margin: 6px 0; }
.ok-msg { color: #166534; font-weight: 800; font-size: 0.9rem; margin: 6px 0; }

/* Barra inferior móvil/tableta */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center; gap: 8px;
  padding: 8px 12px max(10px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 2px solid rgba(74, 38, 23, 0.14);
}
.bottom-nav button {
  flex: 1; max-width: 160px; min-height: 50px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 2px solid transparent; border-radius: 14px; background: transparent;
  cursor: pointer; font-family: 'Fredoka', sans-serif; font-size: 0.82rem; font-weight: 600;
}
.bottom-nav button.active { background: var(--yellow); border-color: var(--ink); }
.bottom-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Diálogos y Toast */
dialog {
  width: min(460px, calc(100vw - 28px));
  border: var(--border); border-radius: 24px;
  background: #FFFBF4; color: var(--ink);
  padding: 22px; box-shadow: 0 14px 34px rgba(74, 38, 23, 0.28);
}
dialog::backdrop { background: rgba(74, 38, 23, 0.45); backdrop-filter: blur(3px); }
dialog h2 { font-size: 1.35rem; margin-bottom: 8px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
dialog .steps { padding-left: 20px; margin: 10px 0; }
dialog .steps li { margin-bottom: 6px; font-weight: 600; }

#toast {
  position: fixed; left: 50%; bottom: 82px; z-index: 60;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-weight: 800; font-size: 0.92rem;
  transition: opacity .2s ease, transform .2s ease;
  max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .levels-grid, .welcome-grid, .grid-2 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kid-hero { grid-template-columns: 1fr; }
}
