:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #1a1d21; --muted: #667085; --line: #e4e7ec;
  --accent: #2e6da4; --accent-ink: #ffffff; --accent-soft: #e8f0f8; --es: #2e6da4;
  --ok: #2f855a; --ok-soft: #e6f4ec; --bad: #c0392b; --bad-soft: #fbeceb; --gold: #b7791f;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 16px rgba(16,24,40,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418; --surface: #1a1f25; --text: #e8eaed; --muted: #98a2b3; --line: #2b323b;
    --accent: #5b9bd5; --accent-ink: #0d1117; --accent-soft: #1d2a38; --es: #7fb3e3;
    --ok: #4cb782; --ok-soft: #16291f; --bad: #e5675a; --bad-soft: #2e1a18; --gold: #e0a84a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #111418; --surface: #1a1f25; --text: #e8eaed; --muted: #98a2b3; --line: #2b323b;
  --accent: #5b9bd5; --accent-ink: #0d1117; --accent-soft: #1d2a38; --es: #7fb3e3;
  --ok: #4cb782; --ok-soft: #16291f; --bad: #e5675a; --bad-soft: #2e1a18; --gold: #e0a84a;
  --shadow: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 16px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
a { color: var(--accent); }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* header / footer */
.top { background: var(--surface); border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.top .wrap { display: flex; align-items: center; gap: 12px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; margin-right: auto; padding: 6px 0; }
.brand img { display: block; height: 52px; width: auto; }
.brand .logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo-light { display: none; }
  :root:not([data-theme="light"]) .brand .logo-dark { display: block; }
}
:root[data-theme="dark"] .brand .logo-light { display: none; }
:root[data-theme="dark"] .brand .logo-dark { display: block; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.nav a, .nav button { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px;
  font: inherit; font-size: 15px; background: none; border: 0; cursor: pointer; }
.nav a:hover, .nav button:hover, .nav a.on { color: var(--text); background: var(--bg); }
.nav form { margin: 0; }
.nav a.icon { display: inline-flex; align-items: center; padding: 6px 8px; }
.foot { color: var(--muted); font-size: 13px; padding: 32px 0; text-align: center; }
.foot a { color: var(--muted); margin: 0 6px; }

/* generic */
main { padding: 24px 0 8px; }
h1 { font-size: 28px; line-height: 1.2; margin: 8px 0 12px; }
h2 { font-size: 20px; margin: 24px 0 8px; }
.muted { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
        box-shadow: var(--shadow); padding: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  padding: 10px 20px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.msgs { list-style: none; padding: 0; margin: 0 0 16px; }
.msgs li { padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); margin-bottom: 8px; }
.msgs li.error { background: var(--bad-soft); }
.msgs li.success { background: var(--ok-soft); }

/* forms */
.form { max-width: 420px; }
.form p { margin: 0 0 14px; }
.form label { display: block; font-weight: 600; margin-bottom: 4px; }
.form input[type=email], .form input[type=password], .form input[type=number], .form input[type=text] {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; }
.form input[type=checkbox] { width: 18px; height: 18px; vertical-align: middle; margin-right: 6px; }
.form .chk label { display: inline; font-weight: 400; }
.errorlist { color: var(--bad); list-style: none; padding: 0; margin: 4px 0 0; font-size: 14px; }
.helptext { color: var(--muted); font-size: 13px; }

/* landing */
.price { text-align: center; }
.price .amount { font-size: 40px; font-weight: 700; }
.price .amount small { font-size: 16px; color: var(--muted); font-weight: 400; }
.price ul { text-align: left; display: inline-block; margin: 8px 0 16px; padding-left: 20px; }

/* study */
.stats { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; margin-bottom: 14px;
  font-size: 14px; color: var(--muted); }
.track { position: relative; border-radius: 99px; }
.bar.total i, .bar.auto i { background: linear-gradient(90deg, var(--accent), var(--ok)); }

/* rewards (rewards.js): same diamond, different scale */
.fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
.toast { position: fixed; left: 50%; top: 72px; z-index: 51; display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; border-radius: 99px; background: var(--surface); color: var(--text); font-weight: 600;
  border: 1px solid var(--gold); box-shadow: 0 6px 24px rgba(0,0,0,.12); white-space: nowrap;
  animation: toast 2.6s ease forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -10px) scale(.95); } 10%, 82% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -6px); } }
.gem-ico { width: 10px; height: 10px; transform: rotate(45deg); background: var(--gold); border-radius: 2px; flex: none; }
.gem-big { width: 34px; height: 34px; margin: 18px auto 22px; transform: rotate(45deg); border-radius: 5px;
  background: linear-gradient(135deg, var(--gold), color-mix(in srgb, var(--gold) 55%, #fff));
  box-shadow: 0 0 22px color-mix(in srgb, var(--gold) 60%, transparent); animation: gem-pop .7s cubic-bezier(.2,1.6,.4,1) both; }
.gem-big.lvl-autonomy { width: 46px; height: 46px; background: linear-gradient(135deg, var(--ok), var(--gold)); }
.gem-big.lvl-final { width: 58px; height: 58px; background: linear-gradient(135deg, var(--accent), var(--ok), var(--gold));
  animation: gem-pop .8s cubic-bezier(.2,1.6,.4,1) both, gem-shine 2.4s ease-in-out .8s infinite; }
@keyframes gem-pop { 0% { transform: rotate(45deg) scale(0); } 100% { transform: rotate(45deg) scale(1); } }
@keyframes gem-shine { 50% { box-shadow: 0 0 40px color-mix(in srgb, var(--gold) 80%, transparent); } }
@media (prefers-reduced-motion: reduce) { .gem-big { animation: none; } .toast { animation-duration: 2.6s; } }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }
.bar.ok i { background: var(--ok); }
.stage-cur { color: var(--text) !important; font-weight: 600; }

.study { min-height: 340px; display: flex; flex-direction: column; }
.chip { display: inline-block; font-size: 12px; color: var(--muted); background: var(--bg);
        border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; }
.phrase { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin: 28px 0 20px; }
.blk { display: flex; flex-direction: column; align-items: center; text-align: center; }
.blk .en { font-size: 22px; line-height: 1.3; }
.blk .en[role=button] { cursor: pointer; border-radius: 6px; padding: 0 4px; margin: 0 -4px; -webkit-tap-highlight-color: transparent;
  transition: background .15s, color .15s; }
.blk .en[role=button]:hover, .blk .en.speaking { background: var(--accent-soft); }
.blk .en.speaking { color: var(--accent); }
.blk .es { font-size: 16px; color: var(--es); visibility: hidden; margin-top: 2px; }
.revealed .blk .es { visibility: visible; }
.row { display: flex; gap: 10px; margin-top: auto; }
.row .btn { flex: 1; }
.listen { align-self: center; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer;
          display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; }
.listen:hover { background: var(--accent-soft); }
/* "Escuchar" always sits in the middle of the free space between the phrase (20px below it) and the buttons */
.study .listen { margin-block: auto; }
.study .listen + .row { margin-top: 20px; }
.verdict { text-align: center; font-weight: 600; margin: 0 0 12px; min-height: 24px; }
.verdict.ok { color: var(--ok); } .verdict.bad { color: var(--bad); }

.q-hint { text-align: center; color: var(--muted); font-size: 14px; margin: 10px 0 8px; }
.qblocks { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.qblk { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); transition: border-color .15s, background .15s; }
.qblk.current { border-color: var(--accent); background: var(--accent-soft); }
.qblk .es { display: block; color: var(--es); font-size: 17px; margin-bottom: 8px; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slot { font: inherit; font-size: 17px; min-width: 46px; height: 38px; padding: 0 10px; border-radius: 9px; cursor: pointer;
  border: 1.5px dashed var(--line); background: transparent; color: var(--text); -webkit-tap-highlight-color: transparent; }
.qblk.current .slot:not(.filled) { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.slot.filled { border: 1px solid var(--accent); background: var(--surface); }
.slot.ok { border-color: var(--ok); background: var(--ok-soft); }
.slot.bad { border-color: var(--bad); background: var(--bad-soft); text-decoration: line-through; }
[hidden] { display: none !important; }
.tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tile { font: inherit; font-size: 18px; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); cursor: pointer; box-shadow: 0 1px 0 var(--line); -webkit-tap-highlight-color: transparent; }
.tile:active { transform: scale(.96); }
.tile.used { visibility: hidden; }
.tile.placed { border-color: var(--accent); background: var(--accent-soft); }
.result .phrase { margin: 4px 0 8px; }
.result .listen { display: flex; margin: 0 auto 4px; }

.center { text-align: center; }
.big { font-size: 44px; line-height: 1; margin: 12px 0; }
.autonomy { color: var(--ok); font-weight: 700; margin: 12px 0; }
.kbd { font-size: 12px; color: var(--muted); text-align: center; margin-top: 10px; }

/* stories */
.story-list { display: grid; gap: 10px; }
.story-list a, .story-list div { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px;
  text-decoration: none; color: var(--text); }
.locked { opacity: .55; }
.story p.en { font-size: 18px; line-height: 1.6; margin: 0; }
.story p.es { color: var(--es); margin: 2px 0 14px; font-size: 15px; }
.story.hide-es p.es { display: none; }
.story.hide-es p.en { margin-bottom: 10px; }
.story hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.legal h2 { font-size: 17px; }
.draft { background: var(--bad-soft); border-radius: 10px; padding: 10px 14px; font-size: 14px; }

@media (max-width: 480px) {
  h1 { font-size: 24px; }
  .blk .en { font-size: 19px; }
}

/* section menu: Estudiar · Repasar · Examen */
.top .tabs-wrap { display: block; min-height: 0; padding-bottom: 12px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 4px 6px;
  border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; position: relative;
  transition: background .15s, color .15s, box-shadow .15s; -webkit-tap-highlight-color: transparent; }
.tabs a svg { width: 22px; height: 22px; }
.tabs a:hover { color: var(--text); }
.tabs a:active { transform: scale(.97); }
.tabs a.on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 2px rgba(16,24,40,.1), 0 2px 8px rgba(16,24,40,.06); }
:root[data-theme="dark"] .tabs a.on { box-shadow: inset 0 0 0 1px var(--line); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tabs a.on { box-shadow: inset 0 0 0 1px var(--line); } }
.tabs .ico { position: relative; display: flex; }
.badge { position: absolute; top: -6px; left: 14px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; line-height: 18px; font-weight: 700; text-align: center;
  box-shadow: 0 0 0 2px var(--bg); }
.tabs a.on .badge { box-shadow: 0 0 0 2px var(--surface); }
.stats-line { color: var(--muted); font-size: 14px; margin: 0 0 12px; }

/* Examen section */
.exam-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-decoration: none; color: var(--text);
  margin-bottom: 10px; padding: 14px 16px; }
.exam-row small { display: block; font-size: 14px; }
.exam-row .go { color: var(--accent); font-weight: 600; white-space: nowrap; }
.level-card p { margin: 0 0 12px; }
.lvl-stats { max-width: 320px; margin: 14px auto; display: grid; gap: 8px; }
.lvl-row { display: grid; grid-template-columns: 34px 1fr 44px; gap: 10px; align-items: center; font-size: 14px; text-align: left; }

/* welcome screen: how much English the learner knows */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.welcome fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.welcome legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choices.three { flex-direction: row; }
.choices.three .choice { flex: 1; justify-content: center; text-align: center; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; -webkit-tap-highlight-color: transparent; }
.choice input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.choices.three .choice input { position: absolute; opacity: 0; pointer-events: none; }
.choices.three .choice { position: relative; }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice b { margin-right: 6px; }
.choices.three .choice b { display: block; margin: 0; }
.choice small { display: block; color: var(--muted); font-size: 14px; margin-top: 4px; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); margin: 20px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.result-note { margin-bottom: 16px; }
.level-card h2 { margin-top: 0; }
.settings-block { margin-bottom: 16px; }
.settings-block p { margin: 0 0 10px; }
.exam-row.done { cursor: default; }
.chip.review { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); }

/* words of a phrase: long press (or tap, in words mode) shows the meaning of a word in this phrase */
.phrase .w { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; border-radius: 4px;
  transition: background .15s, box-shadow .15s; }
.phrase .w.hl { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); color: var(--accent); }
.phrase.words .w { cursor: pointer; text-decoration: underline dotted color-mix(in srgb, var(--accent) 55%, transparent);
  text-decoration-thickness: 2px; text-underline-offset: 5px; }
.gloss { text-align: center; min-height: 26px; margin: -8px 0 6px; font-size: 17px; color: var(--es); }
.gloss b { color: var(--text); font-weight: 600; margin-right: 8px; }
.gloss .muted { font-size: 14px; }
