:root {
  --bg: #f7f7fb; --fg: #1d1d2b; --muted: #6b6b80; --card: #fff; --line: #e3e3ee;
  --brand: #1e3a8a; --brand-2: #06112b; /* azul marino del logo Kitki */ --ok: #15803d; --bad: #b91c1c; --warn: #b45309;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; min-height: 70vh; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; }

.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
/* Altura mínima (no fija): si los enlaces no caben en una línea, la cabecera crece en vez de cortarlos. */
.topbar-in { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 8px 16px;
  flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; }
.brand img { height: 30px; width: auto; display: block; }
.hero-mark { height: 72px; width: auto; display: block; margin-bottom: 18px; }
.box-mark { height: 44px; width: auto; display: block; margin: 0 auto 8px; }
.narrow h1 { text-align: center; }
.topbar nav { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.topbar nav a { text-decoration: none; }
.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; color: var(--brand); font: inherit; cursor: pointer; padding: 0; }

.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 10px 18px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--brand-2); }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn.danger { background: var(--bad); }

.hero { padding: 40px 0 16px; }
.hero h1 { font-size: 2.4rem; margin: 0 0 12px; }
.hero p { font-size: 1.15rem; max-width: 640px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding-left: 20px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; gap: 6px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; text-decoration: none; color: inherit; }
.card:hover { border-color: var(--brand); }
.card h3 { margin: 0; }
.tag { font-size: 13px; color: var(--brand); font-weight: 600; }
.price { font-weight: 700; margin-top: auto; }
.price.big { font-size: 2rem; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chips a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); text-decoration: none; color: var(--fg); }
.chips a.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.narrow { max-width: 420px; margin: 24px auto; }
label { display: block; margin-bottom: 12px; font-weight: 500; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; background: #fff; }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > label { flex: 1 1 180px; }
.row > input, .row > select { flex: 1 1 180px; width: auto; margin: 0; }

.notice { background: #eef2ff; border: 1px solid #c7d2fe; padding: 10px 14px; border-radius: 8px; }
.notice.err { background: #fef2f2; border-color: #fecaca; color: var(--bad); }
.notice.warn { background: #fffbeb; border-color: #fde68a; color: var(--warn); }
/* Códigos por correo */
.code-input { font-size: 1.6rem; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.center-note { text-align: center; margin-top: -8px; }
.linkish { background: none; border: 0; padding: 0; color: var(--brand); text-decoration: underline; font: inherit; cursor: pointer; }

table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 14px; color: var(--muted); }
.list { padding-left: 20px; }

.status { font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eee; }
.st-pending { background: #fef3c7; color: var(--warn); }
.st-in_progress { background: #dbeafe; color: #1d4ed8; }
.st-done { background: #dcfce7; color: var(--ok); }
.st-rejected { background: #fee2e2; color: var(--bad); }
.kind { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.kind-video { color: #be185d; } .kind-quiz { color: #0e7490; } .kind-notes { color: #4d7c0f; }

.stats { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; flex: 1 1 160px; }
.stats b { display: block; font-size: 1.6rem; }
.stats span { color: var(--muted); font-size: 14px; }
.req-head { display: flex; justify-content: space-between; gap: 12px; }

.course-head { margin-bottom: 24px; }
.lead { font-size: 1.1rem; max-width: 720px; white-space: pre-wrap; }
.buybox { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; max-width: 420px; }
.toc li { margin-bottom: 6px; }

/* minmax(0, 1fr): una tabla ancha no puede ensanchar la columna (y con ella la página); se desplaza dentro de su caja. */
.learn { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 32px; }
.side { position: sticky; top: 16px; align-self: start; }
.side ol { padding-left: 20px; }
.lesson { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; }
.lesson h2 { margin-top: 4px; }
.video { position: relative; aspect-ratio: 16 / 9; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 8px; }
.own-video { margin: 8px 0 28px; }
.own-video video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #06112b; border-radius: 10px; }
.own-video p { margin: 6px 0 0; }
.quiz fieldset { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 12px; }
.quiz fieldset.right { border-color: var(--ok); background: #f0fdf4; }
.quiz fieldset.wrong { border-color: var(--bad); background: #fef2f2; }
.opt { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.opt input { width: auto; margin: 0; }
.opt.answer { font-weight: 700; }
.score { margin-left: 12px; font-weight: 700; }
.help { margin-bottom: 12px; font-size: 14px; }
.help pre { background: var(--bg); padding: 8px; border-radius: 6px; }

.foot { background: var(--brand-2); padding: 24px 0; color: #c7cde0; font-size: 14px; }
.foot-in { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.foot-in img { height: 24px; width: auto; }


/* ---------- Zona de estudio (v0.3) ---------- */
.kind-vocab { color: #7c3aed; } .kind-listening { color: #c2410c; } .kind-speaking { color: #be123c; }
.kind-writing { color: #0f766e; } .kind-survey { color: #a16207; } .kind-exam { color: #1e3a8a; }
.kind-counts { display: flex; flex-wrap: wrap; gap: 8px 18px; list-style: none; padding: 0; margin: 0 0 18px; }
.mod-title { margin: 22px 0 6px; font-size: 1.05rem; color: var(--brand-2); }

.learn-head { margin-bottom: 20px; }
.progress-row { display: flex; align-items: center; gap: 12px; margin: 10px 0 16px; }
.progress-row progress { flex: 1; max-width: 420px; height: 12px; accent-color: var(--brand); }
.progress-row.small { margin: 10px 0; font-size: 13px; }
.progress-row.small progress { height: 8px; }
.mod { padding: 16px 20px; }
.mod-head { display: flex; justify-content: space-between; align-items: baseline; }
.mod-head h2 { margin: 0 0 8px; font-size: 1.15rem; }
.lesson-list { list-style: none; margin: 0; padding: 0; }
.lesson-list li a { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 8px; text-decoration: none; color: var(--fg); }
.lesson-list li a:hover { background: var(--bg); }
.lesson-list .ico { width: 26px; text-align: center; }
.lesson-list .t { flex: 1; }
.lesson-list li.done .ico { color: var(--ok); font-weight: 700; }
.lesson-list li.done .t { color: var(--muted); }

.side-nav details { margin-bottom: 6px; }
.side-nav summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 4px 0; }
.side-nav ol { list-style: none; padding: 0 0 0 4px; margin: 4px 0 8px; font-size: 14px; }
.side-nav li a { display: block; padding: 4px 6px; border-radius: 6px; text-decoration: none; color: var(--fg); }
.side-nav li.current a { background: #e0e7ff; font-weight: 600; }
.side-nav li.done .ico { color: var(--ok); }
.lesson-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.lesson h1 { margin: 6px 0 16px; }
.lesson-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 24px; }
.lesson-nav form { margin: 0; }

.notes h2 { margin-top: 26px; font-size: 1.3rem; }
.notes h3 { margin-top: 20px; }
.tip { background: #fffbeb; border-left: 4px solid #f59e0b; padding: 10px 14px; border-radius: 6px; margin: 12px 0; }
.table-wrap { overflow-x: auto; margin: 10px 0 16px; }
.notes-table th { background: #eef2ff; color: var(--fg); }
.notes-table td, .notes-table th { border: 1px solid var(--line); }
h2.sec, h3.sec { margin-top: 26px; }
p.reading { background: #fafaff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; line-height: 1.7; }

.quiz legend { font-weight: 600; padding: 0 4px; }
.quiz fieldset { padding: 8px 14px 12px; }
.opt { padding: 3px 0; }
.explain { margin-top: 8px; background: #f0f9ff; border-radius: 6px; padding: 8px 10px; font-size: 14px; }
.quiz-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.score { font-weight: 700; }
.score.good { color: var(--ok); }
.timer { position: sticky; top: 8px; z-index: 5; margin-left: auto; width: max-content; background: var(--brand-2); color: #fff;
  padding: 6px 14px; border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.low { background: var(--bad); }
.exam-intro { text-align: center; }

.listening .player { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.rate-l { margin: 0; display: flex; gap: 6px; align-items: center; font-weight: 400; }
.rate-l select { width: auto; margin: 0; }
.script { background: var(--bg); border-radius: 8px; padding: 12px 12px 12px 32px; }
.script li { margin-bottom: 4px; }

.say { background: none; border: 0; cursor: pointer; font-size: 1rem; padding: 0 4px; }
.btn.say { font-size: 14px; }
.phrases { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; padding: 10px 14px; margin: 12px 0; }
.phrases summary { cursor: pointer; font-weight: 600; }
.phrases ul { margin: 8px 0 0; }
.prompt-q { font-size: 1.05rem; margin: 0 0 10px; }
.prompt-tools { align-items: center; }
.phase { font-weight: 600; }
.prompt audio { display: block; width: 100%; margin-top: 10px; }
.prompt audio[hidden] { display: none; }
.model { margin-top: 10px; }
.model summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.small-note { font-size: 14px; }
.mail-body { white-space: pre-wrap; font-family: inherit; margin: .5em 0 0; }

.task-q { font-weight: 600; white-space: pre-wrap; }
.wc { font-size: 14px; color: var(--muted); margin-top: 4px; }
.wc.ok { color: var(--ok); font-weight: 600; }
.checklist ul { list-style: none; padding: 0; }
.checklist label { font-weight: 400; display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.checklist input, .s-item input { width: auto; display: inline; margin: 0; }

.s-item { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; padding: 8px 14px; }
.s-item legend { font-weight: 600; }
.s-item label { display: inline-flex; gap: 6px; margin: 4px 16px 0 0; font-weight: 400; }
.s-item.weak { border-color: #f59e0b; background: #fffbeb; }

.vocab-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.flip { position: relative; min-height: 110px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  cursor: pointer; padding: 14px; display: flex; flex-direction: column; justify-content: center; transition: background .2s; }
.flip:hover { border-color: var(--brand); }
.flip .front { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 1.1rem; }
.flip .back { display: none; }
.flip .back small { display: block; color: var(--muted); margin-top: 6px; font-style: italic; }
.flip.flipped { background: #eef2ff; }
.flip.flipped .front { display: none; }
.flip.flipped .back { display: block; }
.practice { text-align: center; }
.pc-es { font-size: 1.5rem; font-weight: 700; margin: 10px 0; }
.pc-en { font-size: 1.3rem; color: var(--brand); font-weight: 700; }
.pc-ex { font-style: italic; margin-top: 4px; }
.practice .row { justify-content: center; margin-top: 14px; }

/* Barra de voz (lecciones con audio) */
.voice-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; margin: -6px 0 16px; font-size: 14px; }
.voice-bar label { margin: 0; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.voice-bar select { width: auto; max-width: 320px; margin: 0; padding: 5px 8px; }
.voice-bar.warn { background: #fffbeb; border-color: #fde68a; color: var(--warn); }
.voice-msg { flex-basis: 100%; margin: 0; font-weight: 600; }

/* Numeración de lecciones e icono de audio (v0.4) */
.lesson-list .ico, .side-nav .ico { display: inline-block; min-width: 22px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.lesson-list li.done .ico, .side-nav li.done .ico { color: var(--ok); font-weight: 700; }
.ico-sound { vertical-align: -3px; }
.say { color: var(--brand); }

/* Condiciones, casilla de aceptación y protección de cuentas */
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 14px; }
label.check input { width: auto; margin-top: 4px; flex: none; }
.prose { max-width: 760px; }
.prose h2 { font-size: 1.15rem; margin-top: 22px; }
.foot a { color: inherit; }
.flag { display: inline-block; background: #fdecec; color: var(--bad); border-radius: 6px; padding: 2px 8px; font-size: 13px; font-weight: 600; }
.flag.ok { background: #e8f5ec; color: var(--ok); }
.reasons { margin: 4px 0 0; padding-left: 18px; color: var(--bad); font-size: 14px; }

/* Marca de agua con el email del alumno (disuasoria: identifica la cuenta en capturas y grabaciones) */
.wm-host { position: relative; }
.wm-tiles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; user-select: none; z-index: 5; }
.wm-tiles span { position: absolute; transform: rotate(-24deg); white-space: nowrap; font-size: 15px; font-weight: 600;
  color: rgba(30, 58, 138, .07); }
.own-video { position: relative; }
.own-video .wm-float { position: absolute; z-index: 6; pointer-events: none; user-select: none; color: rgba(255, 255, 255, .45);
  text-shadow: 0 0 3px rgba(0, 0, 0, .5); font: 600 14px/1 system-ui, sans-serif; transition: top 1.5s, left 1.5s; top: 8%; left: 6%; }
.own-video:fullscreen { background: #000; display: flex; flex-direction: column; justify-content: center; }
.own-video:fullscreen video { height: 100%; border-radius: 0; }
.own-video:fullscreen p { display: none; }
.own-video:fullscreen .wm-float { font-size: 20px; }

/* Solicitud de formación */
.notice.tip { background: #eef2fd; border-left: 4px solid var(--brand); }
.request-form fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px 6px; margin: 0 0 18px; }
.request-form legend { font-weight: 700; color: var(--brand); padding: 0 6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 4px 16px; margin-bottom: 12px; }
.file-list { margin: 6px 0 14px; padding-left: 18px; font-size: 14px; }
.file-list .bad { color: var(--bad); font-weight: 600; }
.req-info { display: grid; grid-template-columns: minmax(160px, 220px) 1fr; gap: 8px 18px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.req-info dt { font-weight: 600; color: var(--muted); }
.req-info dd { margin: 0; }
@media (max-width: 640px) { .req-info { grid-template-columns: 1fr; } .req-info dd { margin-bottom: 8px; } }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.thumbs img { width: 150px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }

/* Índice de la lección (plegable; en ordenador se abre solo) */
.side-toc > summary { cursor: pointer; font-weight: 700; font-size: 14px; padding: 6px 0; }
.side-toc > summary .muted { font-weight: 400; }

@media (max-width: 760px) {
  .learn { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .side { position: static; }
  .hero h1 { font-size: 1.8rem; }
  .side-toc { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 14px; }
  .side-toc > summary { padding: 10px 0; font-size: 15px; }
  .side-toc[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 8px; }
  .side-nav li a { padding: 8px 6px; }
  .side-nav summary { padding: 8px 0; }
}

/* ---------- Móvil ---------- */
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  main.wrap { padding-top: 16px; padding-bottom: 32px; }
  h1 { font-size: 1.6rem; }
  .hero { padding-top: 16px; }
  .hero h1 { font-size: 1.75rem; }
  .hero p { font-size: 1.05rem; }
  .hero-mark { height: 56px; }

  /* Cabecera compacta: logo y enlaces en una línea siempre que quepan. */
  .topbar-in { gap: 6px 12px; }
  .brand img { height: 24px; }
  .topbar nav { gap: 4px 12px; font-size: 15px; }
  .topbar nav .btn.small { padding: 6px 10px; }

  .box, .lesson, .buybox, .mod { padding: 16px; }
  .buybox { max-width: none; }
  .lesson h1 { font-size: 1.45rem; }
  .actions .btn, .buybox .btn { display: block; width: 100%; text-align: center; }
  .lesson-nav .btn { flex: 1 1 auto; text-align: center; }

  /* Tablas: se desplazan de lado dentro de su caja en vez de salirse de la pantalla. */
  main table:not(.notes-table) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  main table:not(.notes-table) td, main table:not(.notes-table) th { min-width: 7.5em; }
  th, td { padding: 8px 10px; }

  /* Formularios: nada más ancho que la pantalla. */
  .row > input, .row > select, .row > label { flex-basis: 100%; min-width: 0; }
  select { max-width: 100%; }
  .voice-bar select { max-width: 100%; }

  /* Zonas de toque más grandes (respuestas de tests, encuestas y casillas). */
  .opt { padding: 7px 0; }
  .opt input, label.check input, .checklist input, .s-item input { width: 20px; height: 20px; flex: none; }
  .s-item label { margin: 6px 16px 2px 0; }
  .quiz fieldset { padding: 8px 12px 10px; margin-left: 0; margin-right: 0; }
  .req-head { flex-wrap: wrap; }
  .kind-counts { gap: 4px 14px; }
  .stats { gap: 10px; }
  .stats div { padding: 12px 14px; flex-basis: 140px; }
}
