/* ===== Colores de marca: cambia estos valores para aplicar otro brandbook ===== */
:root {
  --bg: #F5F7FC;
  --surface: #FFFFFF;
  --surface2: #EEF2FB;
  --ink: #1A2238;
  --muted: #5D6785;
  --line: #E1E6F2;
  --primary: #3D5AF1;
  --primary-ink: #FFFFFF;
  --primary-soft: #E6EBFF;
  --accent: #FFB020;
  --accent-soft: #FFF3D9;
  --ok: #0E9F74;
  --ok-soft: #DDF7EC;
  --bad: #D93F45;
  --bad-soft: #FDE8E8;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(26, 34, 56, .08);
  --font: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
}
[data-theme="dark"] {
  --bg: #0F1424;
  --surface: #182038;
  --surface2: #212B49;
  --ink: #EEF1FA;
  --muted: #A3ADCB;
  --line: #2A355A;
  --primary: #8196FF;
  --primary-ink: #0F1424;
  --primary-soft: #232F5C;
  --accent: #FFC14D;
  --accent-soft: #3D3113;
  --ok: #3DD6A3;
  --ok-soft: #123D32;
  --bad: #FF7B7F;
  --bad-soft: #4A1E22;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink);
  line-height: 1.55; font-size: 16px; display: grid; grid-template-columns: 240px 1fr; min-height: 100vh;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; font-weight: 700; text-wrap: balance; }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .8em; }
a { color: var(--primary); }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ===== Navegación ===== */
.side {
  background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; padding: 0 8px; }
.logo { width: 36px; height: 36px; border-radius: 11px; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-weight: 700; }
#nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
#nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: .95rem; white-space: nowrap;
}
#nav a:hover { background: var(--surface2); color: var(--ink); }
#nav a.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.theme-btn { background: var(--surface2); border: 0; border-radius: 12px; padding: 10px; cursor: pointer; font-size: .85rem; font-weight: 500; }

#view { padding: 32px clamp(16px, 4vw, 48px) 64px; max-width: 1040px; width: 100%; outline: none; min-width: 0; }

/* ===== Piezas base ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.page-head { margin-bottom: 22px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 600; color: var(--primary); margin: 0 0 4px; }
.sub { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.mt { margin-top: 18px; }

.btn {
  border: 0; border-radius: 12px; padding: 11px 20px; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, filter .15s ease; font-size: .95rem;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--surface2); color: var(--ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 7px 12px; font-size: .82rem; border-radius: 10px; }
.icon-btn { border: 0; background: var(--primary-soft); color: var(--primary); width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 1rem; flex: none; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .72rem; font-weight: 600; background: var(--surface2); color: var(--muted); }
.badge.lv { background: var(--primary-soft); color: var(--primary); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.star { background: var(--accent-soft); color: var(--ink); }

/* ===== Inicio ===== */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.tile b { display: block; font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.tile span { color: var(--muted); font-size: .82rem; }
.hero { background: linear-gradient(135deg, var(--primary), #6C4DF0); color: #fff; border: 0; display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; }
.hero .eyebrow { color: rgba(255, 255, 255, .85); }
.hero p { color: rgba(255, 255, 255, .9); margin: 0; }
.hero .btn { background: #fff; color: #2A3FC0; }
.week { display: flex; gap: 8px; margin-top: 10px; }
.week div { flex: 1; text-align: center; font-size: .72rem; color: var(--muted); }
.week i { display: block; height: 34px; border-radius: 10px; background: var(--surface2); margin-bottom: 4px; }
.week .on i { background: var(--ok); }
.week .today i { box-shadow: inset 0 0 0 2px var(--primary); }

/* ===== Listas ===== */
.item { display: block; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; transition: transform .12s ease, border-color .12s ease; }
.item:hover { transform: translateY(-2px); border-color: var(--primary); }
.item h3 { margin: 8px 0 2px; }
.item p { margin: 0; color: var(--muted); font-size: .85rem; }
.section-title { margin: 26px 0 12px; display: flex; align-items: center; gap: 10px; }

.words { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.word { display: flex; align-items: center; gap: 10px; background: var(--surface2); border-radius: 12px; padding: 8px 12px; }
.word b { display: block; font-weight: 600; }
.word span { font-size: .82rem; color: var(--muted); }
.tip { background: var(--accent-soft); border-radius: 12px; padding: 14px 16px; margin: 14px 0; }

/* ===== Sesión de ejercicios ===== */
.session { max-width: 680px; margin: 0 auto; }
.session-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.session-top .x { background: none; border: 0; font-size: 1.1rem; cursor: pointer; color: var(--muted); padding: 6px 10px; }
.bar { flex: 1; height: 12px; border-radius: 99px; background: var(--surface2); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .35s ease; }
.count { font-size: .82rem; color: var(--muted); font-weight: 500; min-width: 44px; text-align: right; }
.ex-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; color: var(--muted); margin: 0 0 8px; }
.ex-q { font-size: 1.25rem; font-weight: 600; margin: 0 0 18px; }
.opts { display: grid; gap: 10px; }
.opt { text-align: left; background: var(--surface); border: 2px solid var(--line); border-radius: 12px; padding: 12px 16px; cursor: pointer; font-weight: 500; }
.opt:hover { border-color: var(--primary); }
.opt.sel { border-color: var(--primary); background: var(--primary-soft); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.txt { width: 100%; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); font-size: 1.05rem; }
.txt:focus { border-color: var(--primary); outline: none; }
input.blank { width: 11em; max-width: 100%; display: inline-block; padding: 4px 10px; font-size: 1.1rem; margin: 0 4px; }
.line, .bank { display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px; padding: 8px; border-radius: 12px; }
.line { border: 2px dashed var(--line); margin-bottom: 12px; }
.chip { background: var(--surface); border: 2px solid var(--line); border-radius: 10px; padding: 7px 13px; cursor: pointer; font-weight: 500; }
.chip:hover { border-color: var(--primary); }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: grid; gap: 8px; align-content: start; }
.match .opt { text-align: center; }
.match .opt.done { border-color: var(--ok); background: var(--ok-soft); opacity: .7; cursor: default; }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.say-target { font-size: 1.3rem; font-weight: 600; margin: 0 0 14px; }
.mic.rec { background: var(--bad); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.heard { margin-top: 12px; min-height: 1.5em; }
.heard .hit { color: var(--ok); font-weight: 600; }
.heard .miss { color: var(--bad); font-weight: 600; text-decoration: underline wavy; }
.feedback { margin-top: 14px; border-radius: 12px; padding: 14px 16px; animation: pop .2s ease; }
.feedback.ok { background: var(--ok-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback b { display: block; }
.feedback.ok b { color: var(--ok); }
.feedback.bad b { color: var(--bad); }
.feedback p { margin: 4px 0 0; font-size: .92rem; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.session-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.summary { text-align: center; max-width: 520px; margin: 30px auto; padding: 36px 24px; }
.big-emoji { font-size: 3.2rem; line-height: 1; margin-bottom: 8px; }
.score { font-size: 1.1rem; font-weight: 600; color: var(--primary); }

/* ===== Tarjetas ===== */
.flash { text-align: center; padding: 40px 22px; min-height: 240px; display: grid; place-items: center; align-content: center; gap: 8px; }
.flash h2 { font-size: 1.9rem; margin: 6px 0; }
.flash .es { font-size: 1.2rem; font-weight: 600; color: var(--primary); margin: 0; }
.flash .exs { color: var(--muted); font-style: italic; margin: 0; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.grades .btn { flex-direction: column; gap: 0; padding: 10px 6px; }
.grades small { font-weight: 400; font-size: .7rem; opacity: .8; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.table-wrap { overflow-x: auto; }

/* ===== Lectura y escritura ===== */
.reading-text { font-size: 1.08rem; line-height: 1.9; max-width: 66ch; }
.w { border-bottom: 2px dotted var(--primary); cursor: pointer; }
.w:hover { background: var(--primary-soft); }
.q { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 0 0 12px; }
.q legend { font-weight: 600; padding: 0 6px; }
.radio { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.radio.right { background: var(--ok-soft); }
.radio.wrong { background: var(--bad-soft); }
textarea.txt { min-height: 200px; resize: vertical; line-height: 1.6; }
.checklist label { display: flex; gap: 10px; padding: 6px 0; cursor: pointer; }
.model { white-space: pre-wrap; background: var(--surface2); border-radius: 12px; padding: 14px 16px; margin-top: 10px; }
details summary { cursor: pointer; font-weight: 600; color: var(--primary); }

/* ===== Profesional y progreso ===== */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { border: 2px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 16px; cursor: pointer; font-weight: 500; }
.tab.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.phrase { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.phrase:last-child { border-bottom: 0; }
.phrase div { flex: 1; min-width: 0; }
.phrase b { display: block; font-weight: 600; }
.phrase span { font-size: .85rem; color: var(--muted); }
.skill { display: grid; grid-template-columns: 110px 1fr 48px; gap: 12px; align-items: center; margin: 10px 0; font-size: .9rem; }
.skill .bar span { background: var(--primary); }
.chart { display: flex; align-items: flex-end; gap: 10px; height: 140px; margin-top: 12px; }
.chart div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; font-size: .72rem; color: var(--muted); }
.chart i { display: block; width: 100%; max-width: 44px; background: var(--primary); border-radius: 8px 8px 3px 3px; min-height: 3px; }
.chart b { font-weight: 600; color: var(--ink); font-size: .72rem; }

/* ===== Flotantes ===== */
.pop {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}
.pop .btn { background: var(--accent); color: #1A2238; }
.pop .close { background: none; border: 0; color: inherit; cursor: pointer; font-size: 1rem; }
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-size: .9rem; font-weight: 500; z-index: 40; box-shadow: var(--shadow); max-width: calc(100vw - 32px); text-align: center; }

/* ===== Móvil ===== */
@media (max-width: 860px) {
  body { display: block; padding-bottom: 72px; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 8px; border-right: 0; border-top: 1px solid var(--line); z-index: 20; gap: 0; }
  .brand, .theme-btn { display: none; }
  #nav { flex-direction: row; overflow-x: auto; gap: 2px; scrollbar-width: none; }
  #nav a { flex-direction: column; gap: 0; font-size: .68rem; padding: 6px 10px; min-width: 64px; align-items: center; }
  #nav a span { font-size: 1.15rem; }
  #view { padding-top: 20px; }
  .pop { bottom: 84px; }
  .grades { grid-template-columns: repeat(2, 1fr); }
  .skill { grid-template-columns: 90px 1fr 42px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
