/* ============================================================
   Curs de català · Olaia — sistema visual JARVIS Academy (claro)
   Tema claro editorial tipo Apple. El gradient de marca se
   conserva como identidad (fills + títulos), con una variante
   más profunda para texto, para garantizar contraste AA.
   Autocontenido: sin CDN, sin webfonts externas, sin librerías.
   ============================================================ */

:root {
  --bg: #fbfbfd;
  --bg-elevated: #f6f6f8;
  --bg-card: #ffffff;
  --bg-card-2: #f2f2f7;
  --border: #e5e5ea;
  --border-strong: #d2d2d7;

  /* Texto — todos los tonos pasan AA (>=4.5:1) sobre #fbfbfd/#fff.
     En claro la jerarquía la marcan tamaño, peso y letter-spacing,
     no la claridad: bajar más el gris rompería el contraste. */
  --text: #1d1d1f;
  --text-dim: #5b5b60;
  --text-faint: #6e6e73;

  /* Gradient de marca — se mantiene intacto para RELLENOS
     (barra de progreso, badges, puntos, bullets, hairlines). */
  --accent: #c779ff;
  --accent-2: #ff5ea0;
  --accent-3: #ff8a3d;
  --gradient: linear-gradient(135deg, #c779ff 0%, #ff5ea0 50%, #ff8a3d 100%);

  /* Variante profunda del MISMO gradient, solo para TEXTO
     (background-clip). Sobre blanco los tonos originales no
     llegan a AA; estos sí, y leen como la misma identidad. */
  --gradient-text: linear-gradient(135deg, #9333ea 0%, #db2777 55%, #c2410c 100%);

  /* Tintas sólidas legibles sobre claro */
  --accent-ink: #7b2fbf;   /* púrpura de marca en texto/iconos */
  --rose-ink: #c2185b;     /* fonética y acentos rosados */

  /* Semáforo de correcciones */
  --green: #1f8a4c;
  --green-ink: #15703c;    /* texto de feedback (AA sobre tinte verde) */
  --green-dim: #e8f7ee;
  --red: #d13438;
  --red-ink: #b52226;
  --red-dim: #fdeeee;
  --amber: #b25e09;
  --amber-ink: #8f4a07;
  --amber-dim: #fdf3e3;

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.07), 0 18px 40px rgba(0, 0, 0, 0.09);

  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius: 18px;
  --radius-sm: 12px;
  --maxw: 1080px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  letter-spacing: -0.011em;
  overflow-x: hidden;
  min-height: 100vh;
  font-size: 16px;
}

a { color: inherit; text-decoration: none; }
::selection { background: rgba(199, 121, 255, 0.28); color: var(--text); }

.wrap { position: relative; z-index: 2; max-width: var(--maxw); margin: 0 auto; padding: 0 28px; }

/* ============================================================
   Tipografía compartida
   ============================================================ */

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.gradient-text {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

h1, h2, h3, h4 { letter-spacing: -0.03em; line-height: 1.15; font-weight: 800; color: var(--text); }

.section-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 900;
  letter-spacing: -0.04em;
  margin-bottom: 14px;
}

.section-lead {
  color: var(--text-dim);
  font-size: 17px;
  max-width: 780px;
  margin-bottom: 40px;
}

.section-head { margin-bottom: 34px; }
.section-head .eyebrow { display: block; margin-bottom: 16px; }

section { scroll-margin-top: 92px; }

/* ============================================================
   Cards genéricas
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-hover); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* ============================================================
   INDEX · Hero
   ============================================================ */

.hero { padding: 96px 0 72px; }

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card-2);
  margin-bottom: 34px;
}

.hero-eyebrow::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gradient);
}

.hero-title {
  font-size: clamp(46px, 8.5vw, 104px);
  font-weight: 900;
  letter-spacing: -0.055em;
  line-height: 0.95;
  margin-bottom: 28px;
}

.hero-sub {
  font-size: clamp(17px, 2vw, 22px);
  color: var(--text-dim);
  line-height: 1.5;
  max-width: 720px;
  margin-bottom: 48px;
  font-weight: 400;
}

/* Flex en vez de grid: al envolver, los items estiran y llenan la fila.
   Con grid quedaba una celda vacía que sobre claro se veía como un
   bloque gris huérfano. Las hairlines son el fondo asomando por el gap. */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.stat { flex: 1 1 150px; padding: 24px 26px; background: var(--bg-card); }
.stat-value { font-size: 30px; font-weight: 900; letter-spacing: -0.04em; line-height: 1; margin-bottom: 8px; }
.stat-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ============================================================
   INDEX · Timeline
   ============================================================ */

.block { padding: 76px 0; border-top: 1px solid var(--border); }

.timeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-top: 8px; }

.tl-step {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 24px 24px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.tl-step::before {
  content: '';
  position: absolute;
  top: 0; left: 24px; right: 24px;
  height: 2px;
  border-radius: 2px;
  background: var(--border-strong);
}

.tl-step.is-key::before { background: var(--gradient); }

.tl-when {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.tl-level { font-size: 26px; font-weight: 900; letter-spacing: -0.04em; margin-bottom: 8px; }
.tl-step.is-key .tl-level { background: var(--gradient-text); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.tl-desc { font-size: 14px; color: var(--text-dim); line-height: 1.5; }

.note {
  margin-top: 28px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: #f9f4ff;
  color: var(--text-dim);
  font-size: 15px;
}

.note strong { color: var(--text); font-weight: 700; }

/* El bullet va como pseudo-elemento posicionado, NO como item flex: con
   flex, cada nodo de texto suelto del <li> se convertía en una columna y
   partía la prosa en trozos. Así el párrafo fluye entero. */
.fact-list { list-style: none; display: grid; gap: 14px; }
.fact-list li {
  position: relative;
  padding-left: 20px;
  font-size: 15.5px;
  color: var(--text-dim);
  line-height: 1.55;
  min-width: 0;
}
.fact-list li strong { color: var(--text); font-weight: 700; }
.fact-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gradient);
}

/* ============================================================
   INDEX · Método
   ============================================================ */

.method-card { display: flex; flex-direction: column; gap: 12px; }
.method-num {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent-ink);
}
.method-card h3 { font-size: 18px; font-weight: 800; }
.method-card p { font-size: 14.5px; color: var(--text-dim); line-height: 1.55; }

/* ============================================================
   INDEX · Mapa del curso
   ============================================================ */

.level { margin-bottom: 56px; }

.level-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 14px 20px;
  padding-bottom: 18px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.level-badge {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(199, 121, 255, 0.45);
  background: rgba(199, 121, 255, 0.10);
  color: var(--accent-ink);
}

.level-name { font-size: 24px; font-weight: 900; letter-spacing: -0.03em; }
.level-meta { margin-left: auto; font-size: 13px; color: var(--text-faint); font-family: var(--mono); letter-spacing: 0.04em; }
.level-hito { flex-basis: 100%; font-size: 14.5px; color: var(--text-dim); }
.level-hito strong { color: var(--text); }

.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 14px; }

.unit {
  position: relative;
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px 20px 18px;
  min-height: 128px;
  box-shadow: var(--shadow-card);
}

.unit-num {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.unit-title { font-size: 16.5px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 8px; line-height: 1.25; }
.unit-topic { font-size: 13.5px; color: var(--text-dim); line-height: 1.45; }

.unit-badge {
  display: inline-block;
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
}

/* Unidades aún no publicadas: atenuadas pero legibles (nada de
   opacidades bajas que sobre blanco borrarían el texto). */
.unit.is-soon { background: var(--bg-elevated); box-shadow: none; }
.unit.is-soon .unit-title { color: var(--text-dim); }
.unit.is-soon .unit-topic, .unit.is-soon .unit-num, .unit.is-soon .unit-badge { color: var(--text-faint); }

.unit.is-open { border-color: rgba(199, 121, 255, 0.5); transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease; }
.unit.is-open:hover { transform: translateY(-4px); border-color: rgba(255, 94, 160, 0.7); box-shadow: 0 18px 38px -18px rgba(199, 121, 255, 0.45), var(--shadow-card); }
.unit.is-open .unit-num { color: var(--accent-ink); }
.unit.is-open .unit-badge {
  border: 0;
  color: #ffffff;
  font-weight: 700;
  background: var(--gradient-text);
}

footer {
  border-top: 1px solid var(--border);
  padding: 40px 0 64px;
  color: var(--text-faint);
  font-size: 13.5px;
  position: relative;
  z-index: 2;
}
footer .wrap { display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; }

/* ============================================================
   UNITAT · Nav superior + progreso
   ============================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(251, 251, 253, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-dim);
  white-space: nowrap;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  transition: color 0.2s, border-color 0.2s;
}
.back-link:hover { color: var(--text); border-color: var(--border-strong); }

.secnav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}
.secnav::-webkit-scrollbar { display: none; }

.secnav a {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 8px 11px;
  border-radius: 8px;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
}
.secnav a:hover { color: var(--text); background: var(--bg-card-2); }
.secnav a.active { color: var(--accent-ink); background: rgba(199, 121, 255, 0.14); }

.done-pill {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  white-space: nowrap;
}
.done-pill b { color: var(--accent-ink); font-weight: 700; }

.progress-track { height: 2px; background: var(--border); }
/* Barra fija de la portada: left/right en vez de width:100% para no
   depender del bloque contenedor. */
.progress-fixed { position: fixed; top: 0; left: 0; right: 0; z-index: 80; }
.progress-bar { height: 100%; width: 0; background: var(--gradient); transition: width 0.15s linear; }

/* ============================================================
   UNITAT · Cabecera y cuerpo
   ============================================================ */

.unit-hero { padding: 64px 0 48px; }
.unit-hero h1 { font-size: clamp(36px, 6vw, 66px); font-weight: 900; letter-spacing: -0.05em; margin: 18px 0 20px; }
.unit-hero .hero-sub { margin-bottom: 34px; }

.howto {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-2);
  border-radius: var(--radius-sm);
  background: #fff5f8;
  padding: 22px 24px;
  color: var(--text-dim);
  font-size: 15px;
  display: grid;
  gap: 12px;
  margin-top: 30px;
}
.howto strong { color: var(--text); }

.unit-section { padding: 60px 0; border-top: 1px solid var(--border); }
.unit-section > h2 {
  font-size: clamp(26px, 3.6vw, 38px);
  font-weight: 900;
  letter-spacing: -0.04em;
  margin-bottom: 10px;
}
.unit-section > .sub { color: var(--text-dim); font-size: 16px; margin-bottom: 32px; max-width: 800px; }

.unit-section h3 {
  font-size: 21px;
  font-weight: 800;
  margin: 42px 0 14px;
  letter-spacing: -0.025em;
}
.unit-section h4 { font-size: 17px; font-weight: 700; margin: 28px 0 12px; color: var(--text); }
.unit-section p { color: var(--text-dim); margin-bottom: 14px; max-width: 860px; }
.unit-section p strong, .unit-section li strong { color: var(--text); font-weight: 700; }

.unit-section ul, .unit-section ol { color: var(--text-dim); margin: 0 0 18px 20px; }
.unit-section li { margin-bottom: 8px; line-height: 1.55; }

code, .ca {
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(199, 121, 255, 0.10);
  border: 1px solid rgba(199, 121, 255, 0.28);
  color: var(--accent-ink);
  /* Se permite el salto de línea: hay fragmentos largos en catalán
     (frases de ejemplo) que con nowrap desbordarían en móvil. */
  overflow-wrap: break-word;
  word-break: normal;
}

.objectius { list-style: none; margin-left: 0; display: grid; gap: 12px; }
.objectius li { position: relative; padding-left: 19px; min-width: 0; }
.objectius li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gradient);
}

.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-sm);
  background: var(--amber-dim);
  padding: 18px 22px;
  margin: 20px 0;
  color: var(--text-dim);
  font-size: 15px;
}
.callout strong { color: var(--text); }
.callout.is-accent { border-left-color: var(--accent); background: #f9f4ff; }

.drill {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  padding: 24px;
  margin: 22px 0;
  box-shadow: var(--shadow-card);
}
.drill p { margin-bottom: 12px; }
.drill .phon { font-family: var(--mono); font-size: 14px; color: var(--rose-ink); line-height: 1.8; }

/* ============================================================
   Tablas
   ============================================================ */

.table-wrap {
  overflow-x: auto;
  margin: 18px 0 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}

table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 420px; }

thead th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
  padding: 13px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text-dim); vertical-align: top; }
tbody tr:nth-child(even) td { background: #fafafc; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f4f4f7; }
tbody td strong { color: var(--text); font-weight: 700; }
td.ca-cell { color: var(--text); font-weight: 600; }
td.phon-cell { font-family: var(--mono); font-size: 13px; color: var(--rose-ink); white-space: nowrap; }
td.speaker { color: var(--accent-ink); font-weight: 700; white-space: nowrap; }

/* Diálogo: ocultar columna ES */
.dialog-table.hide-es .es-col { display: none; }

/* Vocabulario: traducción oculta */
.hide-cell { cursor: pointer; user-select: none; }
.hide-cell .veil {
  display: inline-block;
  min-width: 90px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.vocab-table.masked .hide-cell .veil {
  color: transparent;
  background: linear-gradient(90deg, rgba(199, 121, 255, 0.22), rgba(255, 94, 160, 0.18));
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.vocab-table.masked .hide-cell.revealed .veil { color: var(--text-dim); background: none; box-shadow: none; }
.hide-cell:hover .veil { box-shadow: inset 0 0 0 1px var(--accent); }

/* ============================================================
   Botones
   ============================================================ */

.btn {
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}
.btn:hover { border-color: var(--accent); background: rgba(199, 121, 255, 0.09); color: var(--accent-ink); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  border: 0;
  color: #ffffff;
  font-weight: 700;
  background: var(--gradient-text);
}
.btn-primary:hover { filter: brightness(1.06); background: var(--gradient-text); color: #ffffff; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0 6px; }

.tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.tools .hint { font-size: 13px; color: var(--text-faint); }

/* ============================================================
   Actividades
   ============================================================ */

.activity {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 28px;
  margin-bottom: 26px;
  box-shadow: var(--shadow-card);
}

.act-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 8px; }
.act-num {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(199, 121, 255, 0.4);
  background: rgba(199, 121, 255, 0.10);
  color: var(--accent-ink);
}
.act-title { font-size: 20px; font-weight: 800; letter-spacing: -0.025em; }
.act-state {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green-ink);
  opacity: 0;
  transition: opacity 0.25s;
}
.activity.is-done .act-state { opacity: 1; }
.activity.is-done { border-color: rgba(31, 138, 76, 0.45); }
.act-intro { color: var(--text-dim); font-size: 15px; margin-bottom: 20px; }

.wordbank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  margin-bottom: 22px;
  background: var(--bg-elevated);
}
.wordbank span {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.qlist { list-style: none; margin: 0; display: grid; gap: 16px; }

.q {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  padding: 16px 18px;
}
.q-text { color: var(--text); font-size: 15.5px; margin-bottom: 12px; line-height: 1.5; }
.q-text .n {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  margin-right: 10px;
}
.q-text .gap { color: var(--accent-ink); font-family: var(--mono); }

.opts { display: flex; flex-wrap: wrap; gap: 8px; }

.opt {
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 9px 15px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}
.opt .k { font-family: var(--mono); font-size: 11px; color: var(--text-faint); margin-right: 8px; }
.opt:hover:not(:disabled) { border-color: var(--accent); background: rgba(199, 121, 255, 0.07); }
.opt.selected { border-color: var(--accent); background: rgba(199, 121, 255, 0.14); color: var(--text); }
.opt.correct { border-color: var(--green); background: var(--green-dim); color: var(--text); }
.opt.wrong { border-color: var(--red); background: var(--red-dim); color: var(--text); }
.opt:disabled { cursor: default; }

input.inp, select.sel {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 9px 13px;
  min-width: 150px;
  max-width: 100%;
  transition: border-color 0.18s, box-shadow 0.18s;
}
input.inp:focus, select.sel:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(199, 121, 255, 0.18);
}
input.inp.w-sm { min-width: 110px; width: 130px; }
input.inp.w-lg { width: 100%; }
select.sel { min-width: 90px; }

.q.ok { border-color: rgba(31, 138, 76, 0.5); background: var(--green-dim); }
.q.near { border-color: rgba(178, 94, 9, 0.5); background: var(--amber-dim); }
.q.bad { border-color: rgba(209, 52, 56, 0.5); background: var(--red-dim); }

.q.ok input.inp, .q.ok select.sel { border-color: var(--green); }
.q.near input.inp, .q.near select.sel { border-color: var(--amber); }
.q.bad input.inp, .q.bad select.sel { border-color: var(--red); }

.fb { margin-top: 11px; font-size: 14px; line-height: 1.5; display: none; font-weight: 600; }
.fb.show { display: block; }
.fb.ok { color: var(--green-ink); }
.fb.near { color: var(--amber-ink); }
.fb.bad { color: var(--red-ink); }
.fb .sol { color: var(--text); font-weight: 700; }
.fb .why { display: block; color: var(--text-dim); font-size: 13.5px; margin-top: 4px; font-weight: 400; }

.match-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.match-row .label { flex: 1 1 260px; color: var(--text); font-size: 15px; }
.match-row .label b { color: var(--accent-ink); font-weight: 700; }

.inline-q { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.inline-q .who { font-weight: 700; color: var(--accent-ink); font-size: 14px; min-width: 74px; }
.inline-q .txt { color: var(--text); font-size: 15px; flex: 1 1 240px; }

.solution {
  margin-top: 18px;
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: var(--radius-sm);
  background: #f3faf6;
  color: var(--text-dim);
  font-size: 15px;
}
.solution[hidden] { display: none; }
.solution h4 { margin: 0 0 10px; font-size: 15px; color: var(--text); }
.solution p + h4 { margin-top: 18px; }
.solution blockquote {
  border-left: 2px solid var(--border-strong);
  padding-left: 16px;
  margin: 12px 0;
  color: var(--text);
  font-style: normal;
}
.solution ul { margin: 10px 0 0 20px; }

.score-box {
  margin-top: 22px;
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  display: none;
}
.score-box.show { display: block; }
.score-num { font-size: 44px; font-weight: 900; letter-spacing: -0.05em; line-height: 1; margin-bottom: 10px; }
.score-verdict { font-size: 16px; color: var(--text-dim); }
.score-verdict strong { color: var(--text); }

/* Checklist tasca final */
.checklist { list-style: none; margin: 0; display: grid; gap: 2px; }
.checklist li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
  font-size: 15px;
  color: var(--text-dim);
  cursor: pointer;
}
.checklist li:hover { border-color: var(--border-strong); background: var(--bg-elevated); }
.checklist input[type="checkbox"] { margin-top: 4px; accent-color: #7b2fbf; width: 16px; height: 16px; flex: 0 0 auto; cursor: pointer; }
.checklist .group {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  border: 0;
  background: none;
  padding: 18px 0 4px;
  cursor: default;
}
.checklist .group:hover { border-color: transparent; background: none; }
.check-count { font-family: var(--mono); font-size: 13px; color: var(--text-dim); margin-top: 16px; }
.check-count b { color: var(--accent-ink); }

/* Los items flex/grid no pueden encogerse por debajo de su contenido salvo
   que se les fije min-width: 0. Sin esto, un objetivo largo desbordaba en móvil. */
.objectius li, .fact-list li, .checklist li, .qlist .q, .match-row, .inline-q { min-width: 0; }
.match-row .label, .inline-q .txt, .checklist li > span { min-width: 0; overflow-wrap: break-word; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 860px) {
  .wrap, .topbar-inner { padding-left: 20px; padding-right: 20px; }
  .hero { padding: 68px 0 52px; }
  .block, .unit-section { padding: 52px 0; }
  .units { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .activity { padding: 22px 18px; }
  .level-meta { margin-left: 0; flex-basis: 100%; }
  .done-pill { display: none; }
  table { font-size: 14px; }
}

@media (max-width: 560px) {
  body { font-size: 15.5px; }
  .wrap, .topbar-inner { padding-left: 16px; padding-right: 16px; }
  .stat { padding: 18px 18px; }
  .stat-value { font-size: 25px; }
  .opts { flex-direction: column; align-items: stretch; }
  .opt { width: 100%; }
  input.inp.w-sm { width: 100%; min-width: 0; }
  .back-link span { display: none; }
  .card { padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ============================================================
   VOCABULARI · página de vocabulario por niveles con audio
   Reutiliza tokens, .card, .table-wrap y .btn. Solo añade lo
   que no existía: pestañas, buscador pegajoso, filas de audio.
   ============================================================ */

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.voc-hero { padding: 72px 0 40px; }
.voc-hero .hero-title { font-size: clamp(40px, 7vw, 82px); }
.voc-hero .hero-sub { margin-bottom: 0; }
.voc-hero .howto { border-left-color: var(--accent); background: #f9f4ff; }

/* --- Avisos de voz (no bloqueantes) --- */

.voc-banner {
  margin: 26px 0 0;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-sm);
  background: var(--amber-dim);
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.55;
}
.voc-banner strong { color: var(--text); }
.voc-banner ul { margin: 10px 0 6px 20px; }
.voc-banner li { margin-bottom: 6px; }
.voc-banner[hidden] { display: none; }

/* --- Barra pegajosa: pestañas + buscador ---
   --topbar-h la fija el script con la altura real de la topbar,
   que cambia con el ancho (la nav de secciones envuelve). */

.voc-toolbar {
  position: sticky;
  top: var(--topbar-h, 58px);
  z-index: 40;
  margin: 30px 0 26px;
  padding: 14px 0 12px;
  background: rgba(251, 251, 253, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 12px;
}

.voc-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.voc-tab {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.voc-tab:hover { border-color: var(--accent); color: var(--accent-ink); }
.voc-tab.is-active {
  border-color: transparent;
  color: #ffffff;
  background: var(--gradient-text);
}
.voc-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.voc-tab-n {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-card-2);
  color: var(--text-faint);
}
.voc-tab.is-active .voc-tab-n { background: rgba(255, 255, 255, 0.24); color: #ffffff; }
.voc-tab.is-empty .voc-tab-n { color: var(--red-ink); }

.voc-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.voc-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  min-width: 0;
}
.voc-search-ico {
  position: absolute;
  left: 14px;
  font-size: 15px;
  color: var(--text-faint);
  pointer-events: none;
}
.voc-search input {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 10px 16px 10px 38px;
  width: 100%;
  min-width: 0;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.voc-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(199, 121, 255, 0.18);
}

.voc-toggle.is-on {
  border-color: var(--accent);
  background: rgba(199, 121, 255, 0.14);
  color: var(--accent-ink);
}
.voc-stop:disabled { opacity: 0.45; cursor: default; }
.voc-stop:disabled:hover { border-color: var(--border-strong); background: var(--bg-card); color: var(--text); }

.voc-status {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  min-height: 14px;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Campos semánticos --- */

.voc-panel[hidden] { display: none; }

.voc-field { margin-bottom: 40px; }

.voc-field-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 6px;
}
.voc-field-head h3 { font-size: 21px; font-weight: 800; letter-spacing: -0.03em; }

.voc-field-n {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(199, 121, 255, 0.4);
  background: rgba(199, 121, 255, 0.10);
  color: var(--accent-ink);
}

.voc-play-all { margin-left: auto; font-size: 13px; padding: 8px 15px; }
.voc-play-all.playing {
  border-color: transparent;
  color: #ffffff;
  background: var(--gradient-text);
}
.voc-play-all.playing:hover { color: #ffffff; background: var(--gradient-text); filter: brightness(1.06); }

.voc-field-desc { font-size: 14.5px; color: var(--text-dim); margin-bottom: 4px; }

/* --- Tabla de vocabulario ---
   min-width 0 (a diferencia de las tablas de unidad): estas filas
   se reflujan a bloques en móvil, así que no debe haber scroll. */

.voc-table { min-width: 0; }
.voc-table td.ca-cell { width: 34%; }
.voc-table td.es-cell { color: var(--text-dim); }
.voc-table td.voc-warn { font-size: 13.5px; color: var(--amber-ink); }
.voc-table td.say-cell { width: 1%; text-align: right; padding-left: 6px; white-space: nowrap; }
.voc-table .voc-ca { font-weight: 600; }

/* --- Botón de audio por fila --- */

.say {
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1;
  color: var(--accent-ink);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  width: 34px; height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: border-color 0.18s, background 0.18s, color 0.18s, transform 0.12s;
}
.say:hover { border-color: var(--accent); background: rgba(199, 121, 255, 0.10); }
.say:active { transform: scale(0.94); }
.say:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.say.playing {
  border-color: transparent;
  color: #ffffff;
  background: var(--gradient);
  box-shadow: 0 0 0 4px rgba(199, 121, 255, 0.20);
}

/* Sin voz catalana: los botones siguen activos pero marcados como
   aproximados con un punto naranja (no se ocultan: leer con la voz
   por defecto sigue siendo mejor que nada). */
body.voice-approx .say { position: relative; }
body.voice-approx .say::after {
  content: '';
  position: absolute;
  top: 2px; right: 2px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent-3);
  border: 1px solid var(--bg-card);
}
body.voice-off .say,
body.voice-off .voc-play-all,
body.voice-off .voc-toggle,
body.voice-off .voc-stop { display: none; }

.voc-empty {
  padding: 34px 26px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text-dim);
  text-align: center;
  font-size: 15.5px;
}
.voc-empty strong { color: var(--text); }

/* --- Portada: tarjeta de acceso al vocabulario --- */

.voc-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 26px;
  margin-bottom: 46px;
  padding: 26px 28px;
  border: 1px solid rgba(199, 121, 255, 0.5);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.voc-cta:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 94, 160, 0.7);
  box-shadow: 0 18px 38px -18px rgba(199, 121, 255, 0.45), var(--shadow-card);
}
.voc-cta-body { flex: 1 1 320px; min-width: 0; }
.voc-cta-title { font-size: 21px; font-weight: 900; letter-spacing: -0.03em; margin-bottom: 8px; }
.voc-cta-desc { font-size: 15px; color: var(--text-dim); line-height: 1.5; }
.voc-cta-go {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 11px 20px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--gradient-text);
  white-space: nowrap;
}

/* --- Responsive del vocabulario --- */

@media (max-width: 860px) {
  .voc-hero { padding: 56px 0 32px; }
  .voc-play-all { margin-left: 0; }
}

/* Por debajo de 560 px la tabla se refluye a bloques: cada fila es
   una tarjeta con el catalán arriba, el español debajo y el botón
   de audio anclado a la derecha. Cero scroll horizontal. */
@media (max-width: 560px) {
  .voc-table, .voc-table tbody, .voc-table tr, .voc-table td { display: block; width: auto; }
  .voc-table thead { display: none; }
  .voc-table tr {
    position: relative;
    padding: 12px 58px 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .voc-table tbody tr:last-child { border-bottom: 0; }
  .voc-table tbody tr:nth-child(even) td,
  .voc-table tbody tr:hover td { background: transparent; }
  .voc-table tbody tr:nth-child(even) { background: #fafafc; }
  .voc-table td { border: 0; padding: 1px 0; }
  .voc-table td.ca-cell { width: auto; font-size: 16px; }
  .voc-table td.es-cell { font-size: 14.5px; }
  .voc-table td.voc-warn { margin-top: 5px; }
  .voc-table td.say-cell {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: auto;
    padding: 0;
  }
  .voc-toolbar { margin-top: 22px; }
  .voc-field-head h3 { font-size: 19px; }
  .voc-cta { padding: 22px 18px; }
}

/* ============================================================
   Impresión — el tema claro ya es casi la hoja impresa
   ============================================================ */

@media print {
  .topbar, .progress-fixed, .progress-track, .tools, .btn-row, .btn { display: none !important; }
  .voc-toolbar, .say, .voc-banner, .voc-cta-go { display: none !important; }
  /* Al imprimir se quiere el vocabulario entero, no solo la pestaña activa. */
  .voc-panel[hidden] { display: block !important; }
  .voc-field { break-inside: auto; }

  body { background: #fff; color: #000; font-size: 11pt; }
  .wrap { max-width: none; padding: 0; }

  /* Los gradientes con background-clip no imprimen: se fuerza tinta sólida. */
  .gradient-text, .tl-step.is-key .tl-level, .score-num {
    background: none !important;
    -webkit-text-fill-color: #7b2fbf !important;
    color: #7b2fbf !important;
  }

  .card, .activity, .drill, .unit, .tl-step, .stats, .table-wrap {
    box-shadow: none !important;
    border-color: #bbb !important;
  }

  /* Solo bloques cortos evitan el corte de página: aplicarlo a tablas
     o actividades largas dejaba páginas casi en blanco. */
  .unit, .tl-step, .stat, .q, .callout, .note, .drill { break-inside: avoid; }
  thead { display: table-header-group; }
  h2, h3, h4 { break-after: avoid; }

  .solution[hidden] { display: block !important; }
  .unit-section, .block { border-top: 1px solid #bbb; padding: 22px 0; }
  a { text-decoration: underline; }
  thead th { background: #eee !important; color: #333 !important; }
  tbody tr:nth-child(even) td, tbody tr:hover td { background: transparent !important; }
}
