/* ===================== TEMA / VARIABLES ===================== */
:root {
  --bg: #f7f7fb;
  --panel: #ffffff;
  --panel-2: #f0f1f7;
  --text: #2b2d42;
  --muted: #6b7089;
  --border: #e3e5ee;
  --shadow: rgba(45, 47, 74, 0.12);

  --brand: #58cc02;         /* verde Duolingo */
  --brand-dark: #46a302;
  --blue: #1cb0f6;
  --blue-dark: #1899d6;
  --purple: #6c5ce7;
  --gold: #ffc800;
  --red: #ff4b4b;
  --red-dark: #e63c3c;
  --heart: #ff4b4b;

  --radius: 16px;
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131722;
    --panel: #1b2130;
    --panel-2: #232a3b;
    --text: #eef1f8;
    --muted: #9aa3bd;
    --border: #2c3446;
    --shadow: rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ===================== LAYOUT ===================== */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--panel);
  border-bottom: 2px solid var(--border);
  padding: 12px 18px;
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 20px; letter-spacing: -0.5px; }
.logo .mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--blue));
  display: grid; place-items: center; font-size: 20px;
}
.logo small { display: block; font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: 0; }

.course-pill {
  border: none; color: #fff; background: var(--purple);
  font-weight: 900; font-size: 13px; letter-spacing: .5px;
  padding: 6px 14px; border-radius: 20px; box-shadow: 0 3px 0 rgba(0,0,0,.18);
}
.course-pill:active { transform: translateY(3px); box-shadow: none; }
.stats { margin-left: auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.stat { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 15px; }
.stat .ic { font-size: 18px; }
.stat.streak { color: var(--gold); }
.stat.xp { color: var(--brand); }
.stat.hearts { color: var(--heart); }
.stat.level { color: var(--blue); }

.container { max-width: 820px; margin: 0 auto; padding: 22px 16px 80px; }

/* ===================== BOTONES ===================== */
.btn {
  border: none; border-radius: 14px; padding: 14px 22px;
  font-weight: 800; font-size: 15px; letter-spacing: 0.3px;
  color: #fff; background: var(--brand);
  box-shadow: 0 4px 0 var(--brand-dark);
  transition: transform .05s ease, box-shadow .05s ease, filter .15s;
  text-transform: uppercase;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--brand-dark); }
.btn.blue { background: var(--blue); box-shadow: 0 4px 0 var(--blue-dark); }
.btn.blue:active { box-shadow: 0 0 0 var(--blue-dark); }
.btn.gray { background: var(--panel-2); color: var(--text); box-shadow: 0 4px 0 var(--border); }
.btn.gray:active { box-shadow: 0 0 0 var(--border); }
.btn.red { background: var(--red); box-shadow: 0 4px 0 var(--red-dark); }
.btn.ghost { background: transparent; color: var(--blue); box-shadow: none; border: 2px solid var(--border); }
.btn.big { padding: 16px 28px; font-size: 16px; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.tabbar { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  border: 2px solid var(--border); background: var(--panel);
  color: var(--muted); border-radius: 12px; padding: 10px 16px;
  font-weight: 800; font-size: 14px;
}
.tab.active { color: var(--blue); border-color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, var(--panel)); }

/* ===================== MAPA DE UNIDADES ===================== */
.unit-card {
  background: var(--panel); border: 2px solid var(--border);
  border-radius: var(--radius); margin-bottom: 22px; overflow: hidden;
  box-shadow: 0 6px 18px var(--shadow);
}
.unit-head {
  padding: 18px 20px; color: #fff;
  display: flex; align-items: center; gap: 14px;
}
.unit-head .u-ic { font-size: 30px; }
.unit-head h2 { font-size: 19px; font-weight: 900; }
.unit-head .u-intro { font-size: 13px; opacity: .95; font-weight: 600; margin-top: 3px; }
.unit-head .u-lock { margin-left: auto; font-size: 26px; opacity: .9; }

.lesson-path { padding: 18px 20px 22px; }
.node-row { display: flex; align-items: center; gap: 14px; padding: 8px 0; }
.node {
  width: 62px; height: 62px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 26px; font-weight: 900;
  border: none; color: #fff; position: relative;
  box-shadow: 0 5px 0 rgba(0,0,0,.18);
  transition: transform .05s;
}
.node:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.node.done { background: var(--brand); box-shadow: 0 5px 0 var(--brand-dark); }
.node.current { background: var(--blue); box-shadow: 0 5px 0 var(--blue-dark); animation: pulse 1.6s infinite; }
.node.locked { background: var(--panel-2); color: var(--muted); box-shadow: 0 5px 0 var(--border); cursor: not-allowed; }
.node .crown { position: absolute; top: -10px; right: -6px; font-size: 18px; }
@keyframes pulse { 0%,100%{ box-shadow: 0 5px 0 var(--blue-dark);} 50%{ box-shadow: 0 5px 0 var(--blue-dark), 0 0 0 8px color-mix(in srgb, var(--blue) 25%, transparent);} }

.node-label { font-weight: 800; font-size: 15px; }
.node-label small { display: block; color: var(--muted); font-weight: 700; font-size: 12px; }

.progressbar { height: 14px; background: var(--panel-2); border-radius: 10px; overflow: hidden; margin: 4px 0 0; }
.progressbar > span { display: block; height: 100%; background: var(--brand); border-radius: 10px; transition: width .4s ease; }

/* ===================== LECCIÓN (cards + quiz) ===================== */
.lesson-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.lesson-top .lbar { flex: 1; height: 16px; background: var(--panel-2); border-radius: 10px; overflow: hidden; }
.lesson-top .lbar > span { display: block; height: 100%; background: var(--brand); border-radius: 10px; transition: width .3s; }
.lesson-top .close { font-size: 26px; color: var(--muted); background: none; border: none; font-weight: 900; }
.lesson-top .hearts-mini { color: var(--heart); font-weight: 900; }

.card {
  background: var(--panel); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 26px 24px; box-shadow: 0 6px 18px var(--shadow);
}
.card .kicker { font-size: 13px; font-weight: 800; color: var(--blue); text-transform: uppercase; letter-spacing: .5px; }
.card h3 { font-size: 23px; font-weight: 900; margin: 6px 0 14px; letter-spacing: -0.4px; }
.card .body { font-size: 16px; color: var(--text); }
.card .body b { color: var(--text); }
.card ul { margin: 14px 0 0 4px; padding-left: 20px; }
.card ul li { margin: 8px 0; font-size: 15.5px; }
.card .tip {
  margin-top: 18px; padding: 14px 16px; border-radius: 12px;
  background: color-mix(in srgb, var(--gold) 16%, var(--panel));
  border-left: 5px solid var(--gold); font-size: 14.5px; font-weight: 600;
}
.card .tip b { color: var(--text); }

.q-title { font-size: 20px; font-weight: 900; margin-bottom: 6px; }
.q-hint { color: var(--muted); font-weight: 700; font-size: 13px; margin-bottom: 16px; }

.options { display: flex; flex-direction: column; gap: 12px; }
.opt {
  text-align: left; border: 2px solid var(--border); background: var(--panel);
  border-radius: 14px; padding: 15px 18px; font-weight: 700; font-size: 16px;
  color: var(--text); box-shadow: 0 3px 0 var(--border); transition: all .1s;
  display: flex; align-items: center; gap: 12px;
}
.opt:hover:not(.disabled) { border-color: var(--blue); }
.opt .key { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--border); display: grid; place-items: center; font-size: 13px; flex: none; }
.opt.selected { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, var(--panel)); }
.opt.correct { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 16%, var(--panel)); box-shadow: 0 3px 0 var(--brand-dark); }
.opt.wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 14%, var(--panel)); box-shadow: 0 3px 0 var(--red-dark); }
.opt.disabled { cursor: default; }

/* matching */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-item {
  border: 2px solid var(--border); background: var(--panel); border-radius: 12px;
  padding: 13px 14px; font-weight: 800; font-size: 15px; box-shadow: 0 3px 0 var(--border);
}
.match-item.selected { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, var(--panel)); }
.match-item.matched { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 16%, var(--panel)); opacity: .65; cursor: default; }
.match-item.wrongflash { border-color: var(--red); animation: shake .3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

/* barra inferior de feedback */
.feedback {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  border-top: 3px solid transparent;
  transform: translateY(100%); transition: transform .25s ease;
}
.feedback.show { transform: translateY(0); }
.feedback.ok { background: color-mix(in srgb, var(--brand) 18%, var(--panel)); border-color: var(--brand); }
.feedback.bad { background: color-mix(in srgb, var(--red) 16%, var(--panel)); border-color: var(--red); }
.feedback .fb-inner { max-width: 820px; margin: 0 auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.feedback .fb-txt { flex: 1; min-width: 220px; }
.feedback .fb-txt h4 { font-size: 18px; font-weight: 900; }
.feedback.ok .fb-txt h4 { color: var(--brand-dark); }
.feedback.bad .fb-txt h4 { color: var(--red-dark); }
.feedback .fb-txt p { font-size: 14px; font-weight: 600; color: var(--text); }

.sticky-cta { position: sticky; bottom: 0; padding: 16px 0 6px; background: linear-gradient(transparent, var(--bg) 30%); }

/* ===================== EXAMEN ===================== */
.exam-intro .card { text-align: center; }
.exam-intro .big-num { font-size: 44px; font-weight: 900; color: var(--blue); }
.exam-meta { display: flex; justify-content: center; gap: 26px; margin: 18px 0; flex-wrap: wrap; }
.exam-meta div { font-weight: 800; }
.exam-meta small { display: block; color: var(--muted); font-weight: 700; }

.exam-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.exam-bar .timer { font-weight: 900; font-size: 18px; padding: 6px 14px; border-radius: 10px; background: var(--panel-2); }
.exam-bar .timer.danger { color: #fff; background: var(--red); animation: pulse 1s infinite; }
.exam-bar .qcount { font-weight: 800; color: var(--muted); }

.result-ring { width: 150px; height: 150px; border-radius: 50%; margin: 8px auto 16px; display: grid; place-items: center; font-size: 36px; font-weight: 900; }
.result-pass { background: color-mix(in srgb, var(--brand) 20%, var(--panel)); color: var(--brand-dark); border: 6px solid var(--brand); }
.result-fail { background: color-mix(in srgb, var(--red) 14%, var(--panel)); color: var(--red-dark); border: 6px solid var(--red); }

.review-item { border: 2px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 10px; background: var(--panel); }
.review-item.r-ok { border-left: 5px solid var(--brand); }
.review-item.r-bad { border-left: 5px solid var(--red); }
.review-item .rq { font-weight: 800; font-size: 15px; margin-bottom: 6px; }
.review-item .ra { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.review-item .ra b { color: var(--text); }

/* ===================== PROGRESO ===================== */
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 22px; }
.mini-stat { background: var(--panel); border: 2px solid var(--border); border-radius: 14px; padding: 18px; text-align: center; box-shadow: 0 4px 12px var(--shadow); }
.mini-stat .n { font-size: 30px; font-weight: 900; }
.mini-stat .l { font-size: 12px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }

.unit-progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.unit-progress-row .ic { font-size: 24px; }
.unit-progress-row .name { font-weight: 800; flex: 1; }
.unit-progress-row .pct { font-weight: 900; color: var(--muted); min-width: 44px; text-align: right; }

/* ===================== DESAFÍO DIARIO ===================== */
.daily-streak { display: flex; align-items: center; gap: 16px; }
.daily-streak .flame { font-size: 46px; line-height: 1; }
.week-dots { display: flex; gap: 8px; margin-top: 16px; }
.week-dots .wd {
  flex: 1; text-align: center; font-weight: 900; font-size: 12px; color: var(--muted);
  padding: 8px 0; border-radius: 10px; background: var(--panel-2); border: 2px solid transparent;
}
.week-dots .wd.on { background: color-mix(in srgb, var(--gold) 24%, var(--panel)); color: var(--text); }
.week-dots .wd.today { border-color: var(--blue); }

/* ===================== TARJETAS DE CURSO ===================== */
.course-card {
  display: flex; align-items: center; gap: 16px; padding: 16px;
  background: var(--panel); border: 2px solid var(--border); border-radius: var(--radius);
  margin-bottom: 14px; box-shadow: 0 4px 12px var(--shadow);
}
.course-card .course-ic { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font-size: 28px; flex: none; color: #fff; }
.course-card .course-body { flex: 1; min-width: 0; }
.course-card .course-name { font-weight: 900; font-size: 17px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.course-card .course-short { font-size: 11px; font-weight: 900; color: var(--muted); background: var(--panel-2); padding: 2px 8px; border-radius: 10px; }
.course-card .badge-active { font-size: 11px; font-weight: 900; color: var(--brand); }
.course-card .btn { flex: none; padding: 12px 18px; }

/* toast subir nivel */
.toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: var(--purple); color: #fff; padding: 14px 24px; border-radius: 14px;
  font-weight: 900; box-shadow: 0 8px 24px var(--shadow); z-index: 100; opacity: 0;
  transition: all .3s; pointer-events: none; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.section-title { font-size: 22px; font-weight: 900; margin: 4px 0 16px; letter-spacing: -0.5px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

@media (max-width: 540px) {
  .node { width: 54px; height: 54px; font-size: 22px; }
  .card h3 { font-size: 20px; }
  .stats { gap: 10px; }
  .stat { font-size: 13px; }
}

/* Audit: keep the palette while making labels legible and focus visible. */
.logo h1 { font: inherit; letter-spacing: inherit; }
.unit-head .u-intro { opacity: 1; }
.tab.active { color: #00628b; }
.btn, .btn.blue, .btn.red { color: #111; }
.btn.gray { color: var(--text); }
button:focus-visible, a:focus-visible { outline: 3px solid var(--purple); outline-offset: 4px; }
@media (prefers-color-scheme: dark) { .tab.active { color: #83d5ff; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
