:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --green: #22c55e;
  --green-dark: #15803d;
  --green-soft: #dcfce7;
  --red: #ef4444;
  --red-dark: #b91c1c;
  --red-soft: #fee2e2;
  --blue: #3b82f6;
  --blue-soft: #dbeafe;
  --gold: #f59e0b;
  --locked: #d1d5db;
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: #334155;
    --border-strong: #475569;
    --green-soft: #14532d;
    --red-soft: #7f1d1d;
    --blue-soft: #1e3a8a;
    --locked: #475569;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 640px; margin: 0 auto; min-height: 100%; position: relative; }
h2 { margin: 8px 0 16px; }
h3 { margin: 28px 0 10px; font-size: 1.05rem; }
.muted { color: var(--muted); font-size: .95rem; }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .88em; }
pre { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; overflow-x: auto; white-space: pre; }

/* Barra superior */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--surface); border-bottom: 2px solid var(--border);
}
.brand { font-weight: 800; font-size: 1.15rem; color: var(--text); letter-spacing: -.01em; }
.brand b, .logo b { color: var(--green); }
.stats { display: flex; gap: 14px; }
.stat { display: flex; align-items: center; gap: 4px; font-weight: 700; }

/* Pantallas */
.screen { display: none; padding: 16px 16px 110px; }
.screen.active { display: block; }

.card-soft { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.daily-head { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 8px; }
.bar { height: 14px; background: var(--border); border-radius: 99px; overflow: hidden; flex: 1; }
.bar-fill { height: 100%; width: 0; background: var(--green); border-radius: 99px; transition: width .35s ease; }

/* Ruta */
.unit-header {
  margin: 28px 0 18px; padding: 16px 18px; border-radius: var(--radius); color: #fff;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.18);
}
.unit-header .u-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; opacity: .9; font-weight: 700; }
.unit-header .u-sub { font-size: 1.25rem; font-weight: 800; }
.unit-header .u-progress { font-size: .9rem; opacity: .95; margin-top: 2px; }

.nodes { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.level-tag {
  align-self: stretch; display: flex; align-items: center; gap: 10px; margin: 6px 0 2px;
  font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--c, var(--muted));
}
.level-tag::before, .level-tag::after { content: ""; flex: 1; height: 2px; background: currentColor; opacity: .25; border-radius: 2px; }
.node-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.node {
  width: 76px; height: 72px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 32px; color: #fff; background: var(--c, var(--green));
  box-shadow: 0 6px 0 rgba(0,0,0,.22); transition: transform .08s, box-shadow .08s;
  position: relative;
}
.node:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.22); }
.node.locked { background: var(--locked); cursor: not-allowed; filter: grayscale(1); }
.node.current { animation: bob 1.6s ease-in-out infinite; outline: 4px solid var(--c, var(--green)); outline-offset: 5px; }
.node .check {
  position: absolute; right: -4px; bottom: -2px; background: var(--gold); width: 26px; height: 26px;
  border-radius: 50%; font-size: 14px; display: grid; place-items: center; border: 3px solid var(--bg);
}
.node-label { font-size: .85rem; font-weight: 700; text-align: center; max-width: 150px; color: var(--muted); }
.node-label.on { color: var(--text); }
@keyframes bob { 50% { transform: translateY(-5px); } }

/* Barra de navegación */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 640px; display: flex; background: var(--surface);
  border-top: 2px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
.tab {
  flex: 1; background: none; border: none; padding: 10px 0 12px; font: inherit; font-size: .8rem;
  font-weight: 700; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
}
.tab span { font-size: 1.4rem; }
.tab.active { color: var(--blue); }

/* Botones */
.btn {
  font: inherit; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; font-size: .92rem;
  border: none; border-radius: 14px; padding: 14px 18px; cursor: pointer;
  transition: transform .06s, box-shadow .06s;
}
.btn:active:not(:disabled) { transform: translateY(3px); }
.btn.wide { width: 100%; }
.btn.primary { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-dark); }
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--green-dark); }
.btn.primary.wrong { background: var(--red); box-shadow: 0 4px 0 var(--red-dark); }
.btn:disabled { background: var(--border); color: var(--muted); box-shadow: 0 4px 0 var(--border-strong); cursor: default; }
.btn.secondary { background: var(--surface); color: var(--blue); border: 2px solid var(--border); box-shadow: 0 3px 0 var(--border); }
.btn.danger { background: transparent; color: var(--red); border: 2px solid var(--red-soft); margin-top: 20px; width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 150px; }
.icon-btn { background: none; border: none; font-size: 1.5rem; color: var(--muted); cursor: pointer; padding: 4px 8px; }

/* Perfil */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pstat { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px; color: var(--muted); font-size: .9rem; }
.pstat .big { font-size: 1.8rem; font-weight: 800; color: var(--text); }
.setting {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.setting input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--green); }
.setting select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 2px solid var(--border); background: var(--surface); color: var(--text); }

/* Lección */
.lesson {
  position: fixed; inset: 0; background: var(--bg); z-index: 20;
  display: flex; flex-direction: column; max-width: 640px; margin: 0 auto;
}
.lesson[hidden] { display: none; }
.lesson-top { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.hearts { font-weight: 800; color: var(--red); white-space: nowrap; }
.hearts.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.lesson-body { flex: 1; overflow-y: auto; padding: 8px 16px 24px; }
.lesson-foot { padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); border-top: 2px solid var(--border); background: var(--bg); }
.lesson-foot.ok { background: var(--green-soft); border-color: transparent; }
.lesson-foot.bad { background: var(--red-soft); border-color: transparent; }
.feedback { display: none; margin-bottom: 12px; }
.feedback.show { display: block; }
.feedback .f-title { font-weight: 800; font-size: 1.15rem; }
.lesson-foot.ok .f-title { color: var(--green-dark); }
.lesson-foot.bad .f-title { color: var(--red-dark); }
@media (prefers-color-scheme: dark) {
  .lesson-foot.ok .f-title { color: #86efac; }
  .lesson-foot.bad .f-title { color: #fca5a5; }
}
.feedback .f-text { font-size: .95rem; margin-top: 4px; }

.kind { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--blue); margin: 8px 0 6px; }
.question { font-size: 1.3rem; font-weight: 800; margin: 0 0 20px; }

.theory { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 20px; margin-top: 8px; }
.theory .t-icon { font-size: 2.6rem; }
.theory h2 { font-size: 1.3rem; margin: 8px 0 10px; }
.theory .t-body { font-size: 1.05rem; }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.dots span.on { background: var(--blue); }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  font: inherit; text-align: left; background: var(--surface); color: var(--text);
  border: 2px solid var(--border); border-bottom-width: 4px; border-radius: 14px; padding: 14px 16px; cursor: pointer;
  display: flex; gap: 12px; align-items: center;
}
.option .key {
  flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--border);
  display: grid; place-items: center; font-size: .8rem; font-weight: 800; color: var(--muted);
}
.option.sel { border-color: var(--blue); background: var(--blue-soft); }
.option.sel .key { border-color: var(--blue); color: var(--blue); }
.option.right { border-color: var(--green); background: var(--green-soft); }
.option.wrong { border-color: var(--red); background: var(--red-soft); }
.option:disabled { cursor: default; }
.tf { flex-direction: row; }
.tf .option { flex: 1; justify-content: center; font-weight: 800; font-size: 1.1rem; }

.fill-sentence { font-size: 1.25rem; font-weight: 700; margin-bottom: 20px; }
.blank { display: inline-block; min-width: 90px; border-bottom: 3px solid var(--blue); text-align: center; color: var(--blue); }

/* Ordenar */
.order-answer {
  min-height: 70px; border: 2px dashed var(--border-strong); border-radius: 14px; padding: 10px;
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px;
}
.order-answer:empty::before { content: "Toca las piezas en el orden correcto"; color: var(--muted); font-size: .95rem; padding: 12px 6px; }
.order-pool { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; background: var(--surface); color: var(--text); border: 2px solid var(--border); border-bottom-width: 4px;
  border-radius: 12px; padding: 10px 14px; cursor: pointer; text-align: left;
}
.chip.used { visibility: hidden; }
.order-answer .chip { width: 100%; }
.order-answer .chip .n { color: var(--blue); font-weight: 800; margin-right: 6px; }
.order-answer.right { border-color: var(--green); border-style: solid; background: var(--green-soft); }
.order-answer.wrong { border-color: var(--red); border-style: solid; background: var(--red-soft); }

/* Emparejar */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: flex; flex-direction: column; gap: 10px; }
.match .chip { width: 100%; min-height: 58px; font-size: .95rem; }
.match .chip.sel { border-color: var(--blue); background: var(--blue-soft); }
.match .chip.done { border-color: var(--green); background: var(--green-soft); opacity: .55; cursor: default; }
.match .chip.bad { border-color: var(--red); background: var(--red-soft); animation: shake .35s; }

/* Final */
.finish { text-align: center; padding-top: 30px; }
.finish .big-emoji { font-size: 4.5rem; }
.finish h2 { font-size: 1.6rem; }
.finish-stats { display: flex; gap: 12px; justify-content: center; margin: 22px 0; }
.finish-stats div { border: 2px solid var(--border); border-radius: 14px; padding: 10px 16px; background: var(--surface); min-width: 100px; }
.finish-stats b { display: block; font-size: 1.4rem; }
.challenge { text-align: left; background: var(--surface); border: 2px solid var(--gold); border-radius: var(--radius); padding: 16px; margin-top: 10px; }
.challenge .c-title { font-weight: 800; color: var(--gold); margin-bottom: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 30;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: .95rem;
  max-width: calc(100% - 32px); text-align: center;
}

/* Cuenta y sincronización */
.sync-banner {
  width: 100%; margin-bottom: 12px; font: inherit; font-weight: 700; font-size: .95rem; text-align: left;
  background: var(--blue-soft); color: var(--text); border: 2px solid var(--blue); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer;
}
.sync-dot { font-size: 1rem; }
.account-box { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; }
.account-box p { margin: 0 0 12px; }
.field { display: block; margin-bottom: 12px; font-weight: 700; font-size: .9rem; }
.field input {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-weight: 400; padding: 12px;
  border-radius: 12px; border: 2px solid var(--border); background: var(--bg); color: var(--text);
}
.field input:focus { outline: none; border-color: var(--blue); }
.form-error { color: var(--red); font-size: .9rem; margin: 0 0 10px; min-height: 1em; }

/* ---------- Portada ---------- */
.landing, .auth { min-height: 100vh; padding: 0 16px 40px; }
.landing[hidden], .auth[hidden], #main-app[hidden] { display: none; }
.land-nav, .auth-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; }
.logo { font-weight: 800; font-size: 1.4rem; color: var(--text); text-decoration: none; letter-spacing: -.02em; display: flex; align-items: center; gap: 6px; }
.logo-mark { font-size: 1.5rem; }
.btn.small { padding: 9px 14px; font-size: .8rem; }
.btn.big { padding: 16px 22px; font-size: 1rem; }
.btn.ghost { background: transparent; color: var(--blue); border: 2px solid var(--border); box-shadow: 0 3px 0 var(--border); }
.link-btn { background: none; border: none; font: inherit; color: var(--muted); text-decoration: underline; cursor: pointer; margin-top: 14px; padding: 6px; }

.hero { text-align: center; padding: 18px 0 36px; }
.mascot { position: relative; display: inline-flex; flex-direction: column; align-items: center; margin-bottom: 8px; }
.bubble {
  background: var(--surface); border: 2px solid var(--border); border-radius: 16px; padding: 8px 14px;
  font-weight: 700; font-size: .95rem; position: relative; margin-bottom: 10px;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -9px; width: 14px; height: 14px; background: var(--surface);
  border-right: 2px solid var(--border); border-bottom: 2px solid var(--border); transform: translateX(-50%) rotate(45deg);
}
.bot {
  font-size: 4.5rem; width: 128px; height: 128px; display: grid; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #86efac, var(--green)); box-shadow: 0 8px 0 var(--green-dark);
  animation: bob 2.4s ease-in-out infinite;
}
.hero h1 { font-size: clamp(1.8rem, 6.5vw, 2.6rem); line-height: 1.12; margin: 22px 0 12px; letter-spacing: -.02em; }
.hero .hl { color: var(--green); display: block; }
.lead { color: var(--muted); font-size: 1.08rem; max-width: 30em; margin: 0 auto 24px; }
.cta { display: flex; flex-direction: column; gap: 12px; max-width: 360px; margin: 0 auto; }
.cta[hidden] { display: none; }
.small-note { margin: 4px 0 0; font-size: .88rem; }

.land-section { padding: 26px 0; border-top: 2px solid var(--border); }
.land-section h2, .land-final h2 { text-align: center; font-size: 1.45rem; margin: 0 0 18px; }
.feature-grid { display: grid; gap: 14px; }
@media (min-width: 560px) { .feature-grid { grid-template-columns: repeat(3, 1fr); } }
.feature {
  background: var(--surface); border: 2px solid var(--border); border-bottom: 5px solid var(--c);
  border-radius: var(--radius); padding: 18px;
}
.feature h3 { margin: 8px 0 6px; font-size: 1.05rem; }
.feature p { margin: 0 0 12px; color: var(--muted); font-size: .95rem; }
.f-icon { font-size: 2rem; }
.f-tag { display: inline-block; font-size: .78rem; font-weight: 800; color: var(--c); text-transform: uppercase; letter-spacing: .05em; }

.steps { list-style: none; padding: 0; margin: 0 auto; max-width: 460px; display: flex; flex-direction: column; gap: 16px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.s-num {
  flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--blue); color: #fff;
  font-weight: 800; display: grid; place-items: center; box-shadow: 0 3px 0 #1d4ed8;
}
.land-final { text-align: center; padding: 30px 20px; margin-top: 10px; background: var(--green-soft); border-radius: var(--radius); }
.land-foot { text-align: center; color: var(--muted); font-size: .9rem; padding-top: 26px; }

/* Portada amplia: en ordenador usa más ancho que la app. */
#app.wide { max-width: 1080px; }
.land-nav { gap: 12px; }
.land-links { display: none; gap: 22px; }
.land-links a { color: var(--muted); text-decoration: none; font-weight: 700; font-size: .95rem; }
.land-links a:hover { color: var(--text); }
.land-auth { display: flex; gap: 8px; }
.land-auth[hidden] { display: none; }
.land-reg { display: none; }
.eyebrow {
  display: inline-block; margin: 0 0 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--green-soft); color: var(--green-dark); font-weight: 800; font-size: .85rem;
}
.hero { display: grid; gap: 30px; align-items: center; padding: 22px 0 34px; }
.hero h1 { margin: 14px 0 12px; }
.trust { list-style: none; padding: 0; margin: 20px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; color: var(--muted); font-size: .9rem; font-weight: 600; }

/* Maqueta de una lección */
.hero-demo { position: relative; max-width: 330px; width: 100%; margin: 0 auto; padding: 18px 0 26px; }
.phone {
  background: var(--surface); border: 2px solid var(--border); border-radius: 28px; padding: 18px 16px 20px;
  box-shadow: 0 10px 0 var(--border), 0 24px 50px rgba(15, 23, 42, .12); text-align: left;
}
.ph-top { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; font-weight: 700; }
.ph-bar { flex: 1; height: 12px; border-radius: 99px; background: var(--border); overflow: hidden; }
.ph-bar i { display: block; width: 62%; height: 100%; background: var(--green); border-radius: 99px; }
.ph-heart { color: var(--red); }
.ph-kind { margin: 16px 0 4px; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--blue); }
.ph-q { margin: 0 0 12px; font-weight: 800; font-size: 1.02rem; line-height: 1.3; }
.ph-opt {
  border: 2px solid var(--border); border-bottom-width: 4px; border-radius: 12px; padding: 9px 12px;
  margin-bottom: 8px; font-size: .88rem; font-weight: 600;
}
.ph-opt.ok { border-color: var(--green); background: var(--green-soft); }
.ph-feedback { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--green-soft); color: var(--green-dark); font-size: .85rem; font-weight: 700; }
@media (prefers-color-scheme: dark) { .ph-feedback, .eyebrow { color: #bbf7d0; } }
.float-chip {
  position: absolute; background: var(--surface); border: 2px solid var(--border); border-radius: 999px;
  padding: 7px 12px; font-size: .8rem; font-weight: 800; white-space: nowrap; box-shadow: 0 4px 0 var(--border);
  animation: bob 3s ease-in-out infinite;
}
.chip-streak { top: 0; right: -6px; color: #ea580c; }
.chip-cert { bottom: 4px; left: -6px; color: var(--green-dark); animation-delay: -1.5s; }
@media (prefers-color-scheme: dark) { .chip-cert { color: #86efac; } .chip-streak { color: #fdba74; } }

/* Cifras */
.stats {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0 0 30px;
}
.stats div {
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 14px 10px; text-align: center; display: flex; flex-direction: column;
}
.stats b { font-size: 1.8rem; line-height: 1.1; color: var(--green-dark); }
@media (prefers-color-scheme: dark) { .stats b { color: #86efac; } }
.stats span { color: var(--muted); font-size: .88rem; font-weight: 700; }

.sec-lead { text-align: center; color: var(--muted); max-width: 36em; margin: -6px auto 18px; }
.sub-h { text-align: center; font-size: 1.15rem; margin: 30px 0 10px; }
.unit-list { display: grid; gap: 8px; }
.unit-row {
  display: flex; align-items: center; gap: 12px; background: var(--surface); border: 2px solid var(--border);
  border-left: 6px solid var(--c); border-radius: 12px; padding: 10px 12px;
}
.u-num {
  flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--c); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: .85rem;
}
.u-name { flex: 1; font-weight: 700; font-size: .95rem; }
.u-count { color: var(--muted); font-size: .8rem; font-weight: 700; white-space: nowrap; }
.chip-cloud { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.p-chip {
  background: var(--surface); border: 2px solid var(--border); border-bottom: 4px solid var(--c);
  border-radius: 999px; padding: 7px 13px; font-weight: 700; font-size: .9rem;
}
.perks { display: grid; gap: 12px; }
.perk { display: flex; gap: 12px; background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px; }
.perk > span { font-size: 1.7rem; line-height: 1; }
.perk p { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }
.faq { max-width: 680px; margin: 0 auto; display: grid; gap: 10px; }
.faq details { background: var(--surface); border: 2px solid var(--border); border-radius: 14px; padding: 12px 16px; }
.faq summary { font-weight: 800; cursor: pointer; }
.faq details p { margin: 8px 0 2px; color: var(--muted); }
.land-final { margin-top: 26px; }
.land-final .btn { margin-top: 6px; }
.small-bot { width: 84px; height: 84px; font-size: 2.8rem; margin: 0 auto 10px; }

@media (min-width: 560px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .perks { grid-template-columns: repeat(2, 1fr); }
  .unit-list { grid-template-columns: repeat(2, 1fr); }
  .land-reg { display: inline-block; }
}
@media (min-width: 860px) {
  .land-links { display: flex; }
  .hero { grid-template-columns: 1.15fr .85fr; text-align: left; padding: 40px 0 50px; }
  .hero .lead { margin-left: 0; }
  .hero .cta { flex-direction: row; max-width: none; margin: 0; }
  .trust { justify-content: flex-start; }
  .perks { grid-template-columns: repeat(4, 1fr); }
  .perk { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) { .float-chip, .bot { animation: none; } }

/* ---------- Iniciar sesión / Crear cuenta ---------- */
.auth-card {
  max-width: 420px; margin: 24px auto 0; background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 24px 20px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 1.6rem; }
.auth-card > .muted { margin: 0 0 20px; }
.auth-card .btn.wide { margin-top: 4px; }
.show-pass { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; font-size: .9rem; color: var(--muted); cursor: pointer; }
.show-pass input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.hint[hidden] { display: none; }
.hint { font-size: .85rem; color: var(--muted); margin: -4px 0 10px; }
.auth-closed { background: var(--red-soft); border-radius: 12px; padding: 10px 12px; font-size: .92rem; }
.auth-switch { text-align: center; margin: 18px 0 0; font-size: .95rem; color: var(--muted); }
.auth-switch a { color: var(--blue); font-weight: 800; text-decoration: none; }
.account-box .btn-row { margin-top: 4px; }

/* Ejercicio de escribir un prompt */
.prompt-input {
  width: 100%; box-sizing: border-box; min-height: 140px; resize: vertical; padding: 12px 14px;
  border: 2px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text);
  font: inherit; font-size: 1rem; line-height: 1.45;
}
.prompt-input:focus { outline: none; border-color: var(--blue); }
.prompt-input:disabled { opacity: .75; }
.criteria { margin-top: 14px; padding: 12px 14px; border: 2px dashed var(--border); border-radius: 14px; }
.criteria .c-title { font-weight: 800; font-size: .9rem; margin-bottom: 6px; }
.criteria ul { margin: 0; padding-left: 18px; }
.criteria li { margin: 4px 0; font-size: .95rem; }
.criteria ul.checks { list-style: none; padding-left: 0; }
.criteria label { cursor: pointer; }
.criteria input { margin-right: 4px; transform: scale(1.15); }
.prompt-result { margin-top: 14px; display: grid; gap: 10px; }
.prompt-result:empty { display: none; }
.pr-block { padding: 12px 14px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface); }
.pr-block.ok { border-color: var(--green); }
.pr-block.bad { border-color: var(--red); }
.pr-block ul { margin: 6px 0 0; padding-left: 18px; }
.pr-block li { margin: 3px 0; }
.pr-example { white-space: pre-wrap; word-break: break-word; margin: 6px 0 0; font: inherit; font-size: .95rem; }
/* Cabecera de sección (IA en tu profesión) */
.section-header { margin: 28px 0 14px; padding: 18px 16px; border-radius: 18px; border: 2px solid var(--border); text-align: center; }
.section-header h2 { margin: 0 0 4px; font-size: 1.3rem; }
.section-header p { margin: 0; }

/* ---------- Racha, repaso y examen en la ruta ---------- */
.alert-card {
  display: flex; gap: 10px; align-items: center; margin: 14px 0 0; padding: 12px 14px;
  border-radius: var(--radius); background: #fff7ed; border: 2px solid #fdba74; color: #9a3412; font-weight: 700;
}
.alert-card .a-icon { font-size: 1.5rem; }
.review-card { display: flex; gap: 12px; align-items: center; margin-top: 14px; }
.review-card .rc-icon { font-size: 2rem; }
.review-card .rc-text { flex: 1; min-width: 0; }
.review-card .rc-text .muted { font-size: .9rem; }
.review-card .btn { flex: none; }
.exam-card {
  margin: 30px 0 10px; padding: 20px 18px; border-radius: var(--radius); text-align: center;
  background: linear-gradient(135deg, #fef3c7, #dcfce7); border: 2px solid var(--gold); color: #1f2937;
}
.exam-card.locked { background: var(--surface); border-color: var(--border); color: var(--text); }
.exam-card .ec-icon { font-size: 2.6rem; }
.exam-card h3 { margin: 4px 0 6px; font-size: 1.2rem; }
.exam-card p { margin: 0 0 14px; }
.exam-card .btn-row { justify-content: center; }
.cert-form { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.cert-name, .search {
  font: inherit; padding: 12px; border-radius: 12px; border: 2px solid var(--border-strong);
  background: var(--surface); color: var(--text); flex: 1; min-width: 200px;
}
.cert-name:focus, .search:focus { outline: none; border-color: var(--blue); }
.from { font-size: .85rem; color: var(--muted); font-weight: 700; margin-bottom: 6px; }

/* ---------- Logros ---------- */
.h-row { display: flex; justify-content: space-between; align-items: baseline; }
.h-row .muted { font-size: .9rem; font-weight: 600; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.badge {
  background: var(--surface); border: 2px solid var(--border); border-radius: 14px; padding: 12px 10px;
  text-align: center; opacity: .55;
}
.badge.on { opacity: 1; border-color: var(--gold); }
.badge .b-icon { font-size: 1.8rem; }
.badge .b-name { font-weight: 800; font-size: .9rem; margin-top: 2px; }
.badge .b-text { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.new-badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 0 0 18px; }
.badge-pill { background: #fef3c7; color: #92400e; border: 2px solid var(--gold); border-radius: 99px; padding: 6px 12px; font-weight: 800; font-size: .9rem; }
.cert-box { margin-top: 18px; }

/* ---------- Biblioteca de prompts ---------- */
.lib-tools { display: flex; gap: 10px; margin: 14px 0; align-items: center; }
.lib-tools .btn { flex: none; }
.lib-form { margin-bottom: 14px; }
.lib-form .prompt-input { margin-top: 4px; font-weight: 400; }
.lib-item { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.li-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.li-head .muted { font-size: .85rem; }
.li-from { font-size: .85rem; margin-top: 4px; }
.lib-item .pr-example { margin: 10px 0; max-height: 220px; overflow: auto; }
.lib-item .btn-row .btn { min-width: 0; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .big-emoji { font-size: 3rem; }

/* ---------- Clasificación ---------- */
.rank-me { margin: 14px 0; font-weight: 700; }
.rank-list { list-style: none; padding: 0; margin: 0 0 10px; }
.rank-list li {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin-bottom: 8px;
  background: var(--surface); border: 2px solid var(--border); border-radius: 14px;
}
.rank-list li.me { border-color: var(--blue); background: var(--blue-soft); }
.r-pos { width: 32px; text-align: center; font-weight: 800; font-size: 1.1rem; }
.r-user { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-streak { font-size: .9rem; }

/* ---------- Panel de administrador ---------- */
.admin-head { display: flex; align-items: center; gap: 6px; }
.admin-head h2 { margin: 0; }
#admin .profile-grid { margin: 14px 0; }
#admin .search { width: 100%; margin-bottom: 12px; }
.admin-user { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.admin-user .muted { font-size: .85rem; margin: 2px 0; }
.au-head { display: flex; gap: 8px; align-items: center; }
.au-stats { font-size: .9rem; margin: 4px 0; }
.admin-user .btn-row { margin-top: 10px; }
.admin-user .btn-row .btn { min-width: 0; flex: none; }
.tag { background: var(--blue); color: #fff; font-size: .72rem; font-weight: 800; border-radius: 99px; padding: 2px 8px; text-transform: uppercase; }
.tag.soft { background: var(--border); color: var(--text); }
.admin-pass { display: flex; gap: 8px; margin-top: 10px; }
.admin-pass[hidden], .lib-form[hidden] { display: none; }
.admin-pass input { flex: 1; min-width: 0; font: inherit; padding: 10px; border-radius: 10px; border: 2px solid var(--border-strong); background: var(--bg); color: var(--text); }

/* ---------- Certificado ---------- */
.cert-overlay {
  position: fixed; inset: 0; z-index: 25; background: rgba(15, 23, 42, .75); overflow-y: auto;
  padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.cert-overlay[hidden] { display: none; }
.cert-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.cert-paper {
  width: 100%; max-width: 760px; background: #fffdf7; color: #1f2937; text-align: center;
  padding: 40px 28px; border-radius: 6px; border: 10px double #d4a72c; box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.c-logo { font-size: 1.5rem; font-weight: 800; }
.c-logo b { color: #16a34a; }
.c-kicker { margin-top: 16px; font-size: 1.05rem; letter-spacing: .2em; text-transform: uppercase; font-weight: 800; color: #92400e; }
.c-small { margin: 22px 0 4px; color: #6b7280; }
.c-name { font-family: Georgia, "Times New Roman", serif; font-size: 2.2rem; font-weight: 700; border-bottom: 2px solid #d4a72c; display: inline-block; padding: 0 16px 6px; overflow-wrap: anywhere; }
.c-body { max-width: 520px; margin: 18px auto; line-height: 1.5; }
.c-meta { display: flex; justify-content: center; gap: 40px; flex-wrap: wrap; margin: 24px 0 10px; }
.c-meta span { display: block; font-size: .8rem; color: #6b7280; text-transform: uppercase; letter-spacing: .08em; }
.c-meta b { font-size: 1rem; }
.c-verify { font-size: .8rem; color: #6b7280; overflow-wrap: anywhere; margin: 16px 0 0; }

@media (prefers-color-scheme: dark) {
  .alert-card { background: #431407; border-color: #9a3412; color: #fed7aa; }
  .badge-pill { background: #422006; color: #fde68a; }
}

@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff !important; }
  #app > :not(#cert), .cert-actions { display: none !important; }
  .cert-overlay { position: static; background: none; padding: 0; overflow: visible; }
  .cert-paper { box-shadow: none; max-width: none; }
}

/* ---------- Secciones, glosario y reto semanal ---------- */
.jump { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 4px; scrollbar-width: none; }
.jump::-webkit-scrollbar { display: none; }
.chip-link {
  flex: none; font: inherit; font-size: .85rem; font-weight: 700; padding: 8px 12px; border-radius: 99px;
  border: 2px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.chip-link.glossary-link { border-color: #a855f7; color: #7e22ce; }
.anchor { scroll-margin-top: 70px; }
.section-header { scroll-margin-top: 70px; }
.weekly-card { border-color: #fdba74; }
.weekly-card.done { border-color: var(--border); }
.glo-search { width: 100%; margin: 12px 0; }
.glo-item { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.glo-item h3 { margin: 0 0 4px; font-size: 1.05rem; }
.glo-item p { margin: 4px 0; }
.glo-ex { color: var(--muted); font-size: .92rem; }
@media (prefers-color-scheme: dark) {
  .chip-link.glossary-link { color: #d8b4fe; }
}
#landing [hidden] { display: none !important; }
