@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

/* Prevent iOS/Chrome blue link color bleeding into SVG icons */
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
button { color: inherit; -webkit-tap-highlight-color: transparent; -webkit-text-fill-color: currentColor; }
svg { color: inherit; }

:root {
  --bg:        #ffffff;
  --bg-alt:    #f7f7f7;
  --card:      #ffffff;
  --primary:   #111111;
  --primary-lt:#444444;
  --accent:    #16a34a;
  --accent-lt: #22c55e;
  --text:      #111111;
  --muted:     #888888;
  --border:    #e5e5e5;
  --shadow:    0 1px 6px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.10);
  --red:       #dc2626;
}

/* ── Dark mode ────────────────────────────────────────────────────────────── */
html.dark {
  --bg:        #0d1117;
  --bg-alt:    #161b22;
  --card:      #161b22;
  --primary:   #f0f6fc;
  --primary-lt:#8b949e;
  --accent:    #3fb950;
  --accent-lt: #56d364;
  --text:      #e6edf3;
  --muted:     #8b949e;
  --border:    #30363d;
  --shadow:    0 1px 6px rgba(0,0,0,.4);
  --shadow-lg: 0 4px 24px rgba(0,0,0,.55);
  --red:       #f85149;
}
/* Hover/surface overrides for hardcoded light values */
html.dark .nav-user-menu-item:hover,
html.dark .nav-user-menu-btn:hover        { background: #21262d; color: var(--text); }
html.dark .nav-user-menu-divider          { background: #30363d; }
html.dark .btn-primary                    { background: #238636; border-color: #238636; }
html.dark .btn-primary:hover              { background: #2ea043; border-color: #2ea043; }
html.dark .btn-danger-outline:hover       { background: #2d1a1a; }
html.dark .srs-due                        { background: #2d1f0e; color: #f97316; }
html.dark .srs-soon                       { background: #12261e; color: #39d353; }
html.dark .srs-later                      { background: #21262d; color: #6e7681; }
html.dark .lesson-item:hover              { background: rgba(255,255,255,.03); }
html.dark .split-left .lesson-item        { background: #161b22; border: 1px solid #21262d; border-radius: 10px; margin-bottom: 5px; padding: 10px 12px !important; }
html.dark .split-left .lesson-item:first-child { border-top: 1px solid #21262d !important; }
html.dark .split-left .lesson-item:hover  { background: #1c2128 !important; border-color: #30363d !important; }
html.dark .split-left .lesson-item.is-selected { background: rgba(63,185,80,.07) !important; border-color: #238636 !important; border-left-width: 2px !important; }
html.dark .lesson-delete                  { color: #484f58; }
html.dark .comp-prompt-card               { background: #161b22; border-color: #21262d; box-shadow: 0 8px 48px rgba(0,0,0,.55); }
html.dark .comp-prompt-title             { color: var(--text); }
html.dark .comp-prompt-sub               { color: var(--muted); }
html.dark .comp-prompt-icon              { background: #12261e; }
html.dark .comp-saved--motivation        { background: #12261e; border-color: #238636; color: #56d364; }
html.dark .comp-btn                      { background: transparent; border-color: #30363d; color: var(--text); }
html.dark .comp-btn:hover:not(:disabled) { background: rgba(255,255,255,.04); border-color: var(--score-color, var(--accent)); color: var(--score-color, var(--accent)); }
html.dark .nav-avatar                     { background: #1a3a28; color: #39d353; }
html.dark .confirm-card,
html.dark .intro-card                     { background: #161b22; }
html.dark .confirm-overlay                { background: rgba(0,0,0,.65); }
/* El chip del ícono y el botón Cancelar eran gris claro sobre tarjeta oscura. */
html.dark .confirm-icon-neutral           { background: #21262d; }
html.dark .confirm-icon-neutral svg       { stroke: #8b949e; }
html.dark .confirm-cancel                 { background: #21262d; color: #c9d1d9; border-color: #30363d; }
html.dark .confirm-cancel:hover           { background: #2d333b; }
html.dark .confirm-ok-neutral             { background: #238636; border-color: #238636; color: #fff; }
html.dark .confirm-ok-neutral:hover       { background: #2ea043; }
html.dark .cl-panel                       { background: #161b22; }
html.dark .cl-close:hover                 { background: #21262d; }
html.dark .faq-item                       { border-color: #21262d; }
html.dark .faq-item summary               { color: var(--text); }
html.dark .faq-item[open] .faq-icon       { background: #1a3a28; color: #39d353; border-color: #238636; }
html.dark .faq-icon                       { background: #21262d; border-color: #30363d; color: var(--muted); }
html.dark .motivation-card                { background: linear-gradient(145deg, #12261e 0%, #0f2018 100%); border: 1px solid #238636; }
html.dark .motivation-quote               { color: #e6edf3; }
html.dark .motivation-sub                 { color: #3fb950; opacity: 1; }
html.dark .story-modal-overlay            { background: rgba(0,0,0,.72); }
html.dark .story-modal-panel              { background: #161b22; box-shadow: 0 12px 48px rgba(0,0,0,.55); }
html.dark .modal-header                   { background: #161b22; }
html.dark .pub-form                       { background: #161b22; border-color: #30363d; }
html.dark .share-lock-tip                 { background: #21262d; color: var(--text); }
html.dark .lesson-pract-bar               { background: #21262d; }
html.dark .split-left                     { background: var(--bg); border-right-color: #30363d; }
html.dark .comp-history,
html.dark .time-history,
html.dark .corr-history                   { background: var(--bg-alt); border-color: #30363d; }
html.dark input[type="text"],
html.dark input[type="email"],
html.dark input[type="password"],
html.dark textarea,
html.dark select                          { background: #21262d; border-color: #30363d; color: var(--text); }
html.dark input[type="text"]:focus,
html.dark textarea:focus                  { border-color: var(--accent); }
html.dark .seg-tab                        { background: #21262d; border-color: #30363d; color: var(--muted); }
html.dark .seg-tab.active                 { background: var(--primary); color: var(--bg); }
html.dark .ctrl-pill                      { background: #21262d; border-color: #30363d; }
html.dark .ctrl-pill.active               { background: var(--primary); color: var(--bg); }
html.dark .lesson-pract-fill              { background: var(--accent); }
html.dark .icon-picker                    { background: #161b22; border-color: #30363d; box-shadow: 0 8px 32px rgba(0,0,0,.55); }
html.dark .icon-picker-title              { color: var(--text); }
html.dark .icon-picker-close              { color: var(--muted); }
html.dark .icon-picker-close:hover        { background: #21262d; color: var(--text); }
html.dark .icon-picker-emoji              { color: var(--text); }
html.dark .icon-picker-emoji:hover        { background: #21262d; }
html.dark .icon-picker-none               { border-color: #30363d; color: var(--muted); }
html.dark .icon-picker-none:hover         { border-color: var(--accent); color: var(--accent); }
html.dark .icon-picker-grid::-webkit-scrollbar-thumb { background: #30363d; }
html.dark .topic-pill,
html.dark .diff-pill                      { background: #21262d; border-color: #30363d; }
html.dark .cl-ver-badge                   { background: var(--text); color: var(--bg); }

/* ── Lesson panel dark mode ── */
/* Tarjetas: fondo igual al bg para que se vean como secciones, no cajas */
html.dark .play-card                      { background: transparent; border-bottom-color: #21262d; }
html.dark .play-card.is-active            { background: rgba(63,185,80,.04); }

html.dark .player .btn:hover              { background: #21262d; }
html.dark .word-token.lit,
html.dark .literal-token.lit,
html.dark .natural-token.lit              { background: rgba(63,185,80,.12); color: #56d364; }
html.dark .story-saved-badge              { background: #12261e; border-color: #238636; color: #56d364; }
html.dark .story-card                     { background: #161b22; border-color: #21262d; }
html.dark .story-card:hover               { background: #1c2128; border-color: #30363d; box-shadow: 0 4px 20px rgba(0,0,0,.35); }
html.dark .story-card.selected            { background: rgba(63,185,80,.06); border-color: #238636; box-shadow: 0 0 0 3px rgba(63,185,80,.10); }
html.dark .story-card.saved               { background: rgba(63,185,80,.05); border-color: #238636; }
html.dark .story-card.saved:hover         { background: rgba(63,185,80,.09); border-color: #2ea043; }
html.dark .story-card.saved .story-topic-icon { background: #12261e; border-color: #1f4d2e; }
html.dark .story-topic-icon               { background: #21262d; border-color: #30363d; }
html.dark .lesson-icon-empty              { color: #30363d; }

/* Tabs: todos en estilo underline, sin fondo pill */
html.dark .seg-tabs                       { border-bottom-color: #21262d; }
html.dark .seg-tab                        { background: transparent; color: #6e7681; }
html.dark .seg-tab:hover:not(.active)     { color: #8b949e; background: transparent; }
html.dark .seg-tab.active                 { background: transparent; color: var(--accent); border-bottom-color: var(--accent); }

/* Textos con colores hardcodeados que desaparecen en dark */
html.dark .confirm-title                  { color: var(--text); }
html.dark .intro-icon-wrap                { background: #12261e; }
html.dark .intro-tagline                  { color: var(--muted); }
html.dark .intro-step-body strong         { color: var(--text); }
html.dark .intro-step-body span           { color: var(--muted); }

/* Play button: --primary en dark es #f0f6fc → texto #fff invisible */
html.dark .btn-play                       { background: #e6edf3; color: #0d1117; }
html.dark .btn-play:hover                 { background: #f0f6fc; color: #0d1117; }

/* Player misc */
html.dark .voice-picker .seg-tab.active   { background: transparent; color: var(--accent); border-color: var(--accent); }
html.dark .now-playing span               { color: var(--accent); }
html.dark .dot                            { background: #30363d; }
html.dark .is-active .dot                 { background: var(--accent); }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  padding: 0 20px 80px;
}

.container {
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
  padding-top: 32px;
}

/* ── Nav ── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 44px;
}
.nav-brand {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.03em;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.nav-brand .brand-lang {
  font-size: 11px;
  font-weight: 500;
  color: #bbb;
  letter-spacing: 0;
}
.nav-back {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color .15s;
}
.nav-back:hover { color: var(--primary); }

/* ── Nav user ── */
.nav-user {
  display: flex; align-items: center; gap: 8px;
  position: relative; cursor: pointer; user-select: none;
  padding: 4px 6px; border-radius: 8px; margin-right: -6px;
  transition: background .15s;
}
.nav-user:hover { background: rgba(0,0,0,.05); }
.nav-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.nav-username {
  font-size: 13px; font-weight: 500; color: var(--text);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-user-caret {
  color: var(--muted); flex-shrink: 0;
  transition: transform .2s; margin-left: -2px;
}
.nav-user.open .nav-user-caret { transform: rotate(180deg); }
.nav-user-menu {
  display: none;
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 4px 24px rgba(0,0,0,.12);
  min-width: 170px; z-index: 300; overflow: hidden;
}
.nav-user.open .nav-user-menu { display: block; }
.nav-user-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; font-size: 13px; font-weight: 500;
  color: var(--text); text-decoration: none;
  /* El menu se ensancha hasta la etiqueta mas larga en vez de partirla en dos
     lineas: una entrada a dos renglones entre otras de uno se lee como un
     error de maquetacion. */
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.nav-user-menu-item:hover { background: #fef2f2; color: #dc2626; }

/* Aviso de respuestas sin leer. Empujado a la derecha para que no baile
   según el largo del texto del menú. */
.nav-aviso {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent, #16a34a); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  font-variant-numeric: tabular-nums;
}
html.dark .nav-aviso { background: #238636; }

/* ── Badge ── */
.badge {
  display: inline-block;
  background: none;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .10em;
  padding: 0;
  margin-bottom: 10px;
  text-transform: uppercase;
  border: none;
}

/* ── Typography ── */
h1 {
  font-size: clamp(26px, 5vw, 40px);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
  color: var(--primary);
}
.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 6px;
}
/* ── El progreso de la práctica, en anillo ────────────────────────────────────
   Antes era una barra fina perdida entre dos líneas de texto: decía el dato
   pero no se veía. Un anillo a la derecha ocupa el hueco que ya había y se
   lee de un vistazo, que es lo que uno quiere saber al abrir — cuánto llevo. */
/* El texto y el anillo son una sola columna de la cabecera, repartida en dos.
   Antes el anillo era un tercer hermano de `.lesson-header`, y tres columnas
   en un panel estrecho se envuelven: los botones caian debajo y quedaba un
   hueco muerto entre el titulo y ellos. */
.lesson-texto { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 18px; }
.lesson-texto-col { flex: 1; min-width: 0; }

.prog-anillo {
  position: relative; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center;
}
.prog-anillo svg { display: block; transform: rotate(-90deg); }
.prog-pista {
  fill: none; stroke: var(--border); stroke-width: 8;
}
.prog-arco {
  fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round;
  /* La vuelta entera como patrón de trazo, y el hueco animado desde «nada
     pintado» hasta lo que toca. */
  stroke-dasharray: var(--circ);
  stroke-dashoffset: var(--circ);
  animation: prog-dibuja 1.1s cubic-bezier(.22,.8,.3,1) .15s forwards;
}
@keyframes prog-dibuja {
  to { stroke-dashoffset: var(--resto); }
}
/* Quien pide menos movimiento ve el arco ya dibujado, no uno que no aparece. */
@media (prefers-reduced-motion: reduce) {
  .prog-arco { animation: none; stroke-dashoffset: var(--resto); }
}

.prog-centro {
  position: absolute; top: 48px; left: 0; right: 0;
  transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  pointer-events: none;
}
.prog-num { font-size: 19px; font-weight: 800; color: var(--text); line-height: 1; }
.prog-de  { font-size: 12px; font-weight: 600; color: var(--muted); }
.prog-rot {
  font-size: 9px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.prog-pie { font-size: 11px; color: var(--muted); margin: 6px 0 0; white-space: nowrap; }

@media (max-width: 560px) {
  /* En un teléfono el anillo comparte fila con el título, así que se encoge
     en vez de empujar el texto a dos palabras por línea. */
  .prog-anillo svg { width: 74px; height: 74px; }
  .prog-centro { top: 37px; }
  .prog-num { font-size: 16px; }
  .prog-pie { font-size: 10px; }
}

.subtitle-practice {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pract-bar-wrap {
  display: inline-block;
  width: 60px; height: 4px;
  background: #d1fae5;
  border-radius: 2px;
  overflow: hidden;
  vertical-align: middle;
  flex-shrink: 0;
}
.pract-bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

/* ── Buttons ── */
.btn {
  /* En línea y en bloque a la vez: era inline-block, así que un icono dentro
     se apoyaba en la línea base y quedaba descolgado del texto. */
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid var(--border);
  color: var(--primary);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 8px;
  transition: background .15s, border-color .15s, color .15s,
              box-shadow .15s, transform .1s;
  text-decoration: none;
  background: var(--bg);
  -webkit-appearance: none;
}
/* Un icono suelto mide 24 px y estiraba el botón al doble de alto. Solo se le
   pone medida al que no traiga la suya. */
.btn svg:not([width]) { width: 15px; height: 15px; flex-shrink: 0; }
.btn:hover { background: var(--bg-alt); border-color: var(--border); }
/* Se hunde al pulsar. Sin esto, en el teléfono no hay forma de saber si el
   toque entró hasta que cambia la pantalla, y se vuelve a tocar. */
.btn:active:not(:disabled) { transform: translateY(1px); }
/* Y quien va con el teclado tenía que adivinar dónde estaba: no había anillo
   de foco en ningún botón de la app. */
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: #2a2a2a; border-color: #2a2a2a; color: #ffffff; }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-danger-outline { background: var(--bg); border-color: #dc2626; color: #dc2626; }
.btn-danger-outline:hover { background: #fef2f2; border-color: #b91c1c; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
/* El principal de una pantalla: el que se busca sin leer. */
.btn-lg { font-size: 15px; font-weight: 700; padding: 13px 24px; border-radius: 12px; }
.btn-lg svg:not([width]) { width: 17px; height: 17px; }
.btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.pub-btn-active { border-color: var(--accent); color: var(--accent); }
.pub-btn-active:hover { background: #f0fdf4; border-color: #15803d; color: #15803d; }
.share-lock-wrap { position:relative; display:inline-flex; }
.share-lock-tip {
  opacity:0; pointer-events:none;
  position:absolute; top:calc(100% + 8px); left:50%;
  transform:translateX(-50%);
  background:#1f2937; color:#fff;
  font-size:11px; padding:5px 10px; border-radius:6px;
  white-space:nowrap; display:flex; align-items:center; gap:5px;
  transition:opacity .15s; z-index:20;
}
.share-lock-tip::before {
  content:''; position:absolute; bottom:100%; left:50%; transform:translateX(-50%);
  border:5px solid transparent; border-bottom-color:#1f2937;
}
.share-lock-wrap:hover .share-lock-tip,
.share-lock-tip.flash { opacity:1; }

/* ── Form ── */
.field { margin-bottom: 20px; }
label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: .07em;
}
input[type="text"], textarea {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 11px 14px;
  border-radius: 8px;
  outline: none;
  transition: border-color .15s;
  resize: vertical;
}
input[type="text"]:focus, textarea:focus { border-color: var(--primary); }
input::placeholder, textarea::placeholder { color: #ccc; }

/* ── Lesson list ── */
.lesson-list { margin-bottom: 8px; display: flex; flex-direction: column; gap: 0; }
.lesson-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 0 20px;
}
.pager-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.pager-btn:hover:not(:disabled) { background: var(--bg-alt); }
.pager-btn:disabled { opacity: .3; cursor: default; }
.pager-info { font-size: 12px; color: var(--muted); font-weight: 500; min-width: 40px; text-align: center; }
/* El paginador de las tablas de datos (paginador.js). Es el mismo de la lista
   de prácticas, solo que separado de la tabla en vez de pegado al borde. */
.tabla-pager { justify-content: center; padding: 14px 0 2px; }
.lesson-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
  transition: background .12s;
  border-radius: 0;
  box-shadow: none;
}
.lesson-item:first-child { border-top: 1px solid var(--border); }
.lesson-item:hover { background: var(--bg-alt); }
.lesson-body { flex: 1; min-width: 0; color: inherit; text-decoration: none; display: block; }
.lesson-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lesson-meta { font-size: 12px; color: var(--muted); line-height: 1.4; }
.lesson-footer {
  display: flex; align-items: center; gap: 6px; margin-top: 6px;
}
.lesson-pract-inline {
  display: flex; align-items: center; gap: 5px; flex: 1; min-width: 0;
}
.lesson-pract-badge {
  font-size: 10px; font-weight: 600; color: var(--accent);
  white-space: nowrap; flex-shrink: 0;
}
.lesson-pract-bar {
  flex: 1; height: 3px; background: #d1fae5;
  border-radius: 2px; overflow: hidden; min-width: 24px;
}
.lesson-pract-fill {
  height: 100%; background: var(--accent);
  border-radius: 2px; transition: width .3s ease;
}
.srs-badge {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px; white-space: nowrap; flex-shrink: 0;
  letter-spacing: .04em; text-transform: uppercase; vertical-align: middle;
}
.srs-due     { background: #fff7ed; color: #c2410c; }
.srs-soon    { background: #f0fdf4; color: #15803d; }
.srs-later   { background: #f5f5f5; color: #999; }
.lesson-delete {
  background: none;
  border: none;
  color: #d0d0d0;
  cursor: pointer;
  font-size: 14px;
  padding: 5px 9px;
  flex-shrink: 0;
  border-radius: 6px;
  transition: color .15s, background .15s;
  margin-left: -4px;
  margin-right: 12px;
}
.lesson-delete:hover { color: var(--red); background: rgba(220,38,38,0.07); }
.empty {
  text-align: center;
  padding: 60px 0;
  color: var(--muted);
  font-size: 14px;
}

/* ── Lesson header ── */
.lesson-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.lesson-actions { display: flex; gap: 8px; flex-shrink: 0; margin-top: 4px; }
.edit-title-wrap { display: none; margin-bottom: 20px; }
.edit-title-wrap.visible { display: block; }
.edit-title-row { display: flex; gap: 8px; align-items: center; }
.edit-title-wrap input { font-size: clamp(16px, 4vw, 22px); font-weight: 700; flex: 1; }
.edit-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
#btn-repair { color: var(--muted); font-size: 11px; padding: 5px 10px; margin-left: auto; }

/* ── Editar desde el español (lesson.php) ── */
.ed-es { margin-top: 16px; padding: 14px 16px 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-alt); }
.ed-es textarea { width: 100%; margin-top: 8px; }
.ed-paso { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.ed-num {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
}
.ed-paso-t { font-size: 13.5px; font-weight: 700; color: var(--text); }
.ed-fila { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ed-lab { font-size: 12.5px; color: var(--muted); }
.ed-chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
}
.ed-chip:hover:not(:disabled) { border-color: var(--accent); }
.ed-chip.active { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.ed-chip:disabled { opacity: .5; cursor: default; }
.ed-nota { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.ed-nota button, .ed-link {
  border: none; background: none; padding: 0; cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--accent); text-decoration: underline;
}
.ed-paso .ed-link { margin-left: auto; }
.ed-abrir-es { display: block; margin-top: 14px; }
.ed-abrir-es[hidden], .ed-paso[hidden] { display: none; }
.ed-ayuda { font-size: 12px; color: var(--muted); }
.ed-ayuda.aviso { color: #b45309; font-weight: 600; }
html.dark .ed-ayuda.aviso { color: #f0b429; }
.ed-primera {
  margin-top: 8px; padding: 10px 12px; border-radius: 10px;
  border: 1px dashed var(--border); background: var(--card);
}
.ed-primera-t { margin: 0 0 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.ed-primera-txt { white-space: pre-wrap; font-size: 13.5px; color: var(--text); margin-bottom: 10px; }
/* Recién traducido: un destello para que se vea dónde cayó el cambio. */
@keyframes ed-destello { from { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); } to { box-shadow: 0 0 0 3px transparent; } }
.ed-recien { animation: ed-destello 1.6s ease-out; }

/* Lo que la IA no pudo aclarar sola al mejorar la redacción (new.php y
   lesson.php). Se queda hasta la próxima mejora: es para corregirlo tecleando. */
.np-red-avisos {
  margin: 10px 0 0; padding: 10px 14px; border-radius: 10px;
  border: 1px solid color-mix(in srgb, #d97706 40%, var(--border));
  background: color-mix(in srgb, #d97706 8%, transparent);
  font-size: 12.5px; color: var(--text);
}
.np-red-avisos[hidden] { display: none; }
.np-red-avisos-t { margin: 0 0 4px; font-weight: 600; }
.np-red-avisos ul { margin: 0; padding-left: 18px; }
.np-red-avisos li { margin: 3px 0; line-height: 1.45; }

/* ── Segment tabs (underline style) ── */
.seg-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.seg-tabs::-webkit-scrollbar { display: none; }
.seg-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 0;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.seg-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.seg-tab:hover:not(.active) { color: var(--primary-lt); }

.now-playing { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.now-playing span { color: var(--primary); font-weight: 600; }

/* ── Player cards ── */
/* ── Las frases, en carrusel ──────────────────────────────────────────────────
   Antes eran pestañas que solo decían «F1, F2, F3…»: había que entrar en cada
   una para saber qué frase era. Ahora cada tarjeta lleva su texto dentro, y la
   fila se arrastra en vez de salirse de la pantalla — la práctica más larga de
   la casa tiene 39 frases, que son 40 pestañas en una sola línea. */
.frases-carrusel {
  display: flex; gap: 8px; border-bottom: none;
  overflow-x: auto; scroll-snap-type: x proximity;
  margin: 0 -4px 4px; padding: 2px 4px 12px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.frases-carrusel::-webkit-scrollbar { display: none; }

.frase-card {
  flex: 0 0 150px; scroll-snap-align: start;
  display: flex; flex-direction: column; gap: 5px;
  text-align: left; cursor: pointer;
  padding: 9px 11px 10px; border-radius: 11px;
  background: var(--card, #fff); border: 1.5px solid var(--border);
  font-family: inherit; color: var(--text);
  transition: border-color .15s, background .15s;
}
.frase-card:hover { border-color: var(--muted); }
.frase-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Tres estados y tres fondos, de menos a más: sin tocar, practicada, y la que
   suena ahora. El verde de «practicada» es un velo —la mitad del de la activa—
   y se queda con el borde gris; la activa lleva el suyo verde. Con los dos al
   mismo tono se confundían: parecía que sonaban dos a la vez. */
.frase-card.practicada {
  background: color-mix(in srgb, var(--accent) 10%, var(--card, #fff));
}
.frase-card.active,
.frase-card.active.practicada {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 26%, var(--card, #fff));
}
.frase-card-num {
  display: flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
}
.frase-card.active .frase-card-num { color: var(--accent); }
.frase-card-ok {
  color: var(--accent); font-size: 11px; letter-spacing: 0;
  display: inline-flex; align-items: center; gap: 3px;
}
/* El número va más callado que la palomita: lo primero es «está hecha», y
   cuántas veces es el detalle. */
.frase-card-veces {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0;
  color: var(--accent); opacity: .72;
  font-variant-numeric: tabular-nums;
}
/* Dos lineas y corta: es una pista para reconocer la frase, no para leerla. */
.frase-card-txt {
  font-size: 12px; line-height: 1.35; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.frase-card.es-todas .frase-card-txt { color: var(--muted); }

@media (max-width: 560px) { .frase-card { flex-basis: 132px; } }

.play-card {
  background: var(--card);
  border-radius: 0;
  padding: 20px 0;
  margin-bottom: 0;
  box-shadow: none;
  border: none;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.play-card.is-active { background: #fafff9; }

.card-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .10em;
  text-transform: uppercase;
  /* Pildora verde, la misma que el distintivo de «Crear una practica». En
     gris estos rotulos se perdian contra el texto de la frase, que es lo
     unico con peso alrededor; con fondo se leen como lo que son: la etiqueta
     de cada capa. */
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
  /* inline-flex y no flex: la pildora mide lo que su texto, no toda la fila. */
  display: inline-flex;
  /* Y esto es lo que la sujeta cuando su tarjeta es un contenedor flex:
     ahi el navegador convierte el `inline-flex` del hijo en `flex`, y con el
     estirado por defecto la pildora cruzaba la pantalla entera. Le pasaba a
     la de «palabra por palabra», la unica cuya tarjeta es flex. */
  align-self: flex-start;
  align-items: center;
  gap: 7px;
  width: fit-content;
}
html.dark .card-label { background: color-mix(in srgb, var(--accent) 18%, transparent); }
/* El «· igual» de «sin contracciones» no es un rotulo, es una nota al margen:
   se queda apagado para que no compita con el. */
#card-nocontract.no-change .card-label::after { color: var(--muted); }
.dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  transition: background .2s;
}
.is-active .dot { background: var(--accent); }

/* Text inside cards */
.sentence-text {
  font-size: clamp(15px, 3vw, 20px);
  font-style: normal;
  line-height: 1.8;
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 1px;
}
.word-token { padding: 1px 0.15em; border-radius: 3px; color: var(--text); transition: background .15s, color .15s; }
.word-token.lit { background: rgba(22,163,74,0.13); color: #15803d; font-weight: 600; }

.literal-text {
  font-size: clamp(13px, 2.8vw, 15px);
  color: var(--muted);
  line-height: 1.8;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 1px;
}
.literal-token { padding: 1px 0.15em; border-radius: 3px; transition: background .15s, color .15s; }
.literal-token.lit { background: rgba(22,163,74,0.13); color: #15803d; font-weight: 600; }

.natural-text { font-size: clamp(13px, 2.8vw, 15px); color: var(--primary-lt); line-height: 1.8; font-weight: 500; }
.natural-token { padding: 1px 0.15em; border-radius: 3px; transition: background .15s, color .15s; }
.natural-token.lit { background: rgba(22,163,74,0.13); color: #15803d; font-weight: 600; }
.nocontract-text { color: var(--accent); }
.nocontract-text .word-token { color: var(--accent); }
#card-nocontract.no-change .nocontract-text { color: var(--text-muted); }
#card-nocontract.no-change .nocontract-text .word-token { color: var(--text-muted); }
#card-nocontract.no-change .card-label::after { content: " · igual"; font-weight: 400; opacity: 0.5; }

.word-pair { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.word-en { font-size: clamp(22px, 5vw, 34px); font-weight: 700; color: var(--primary); letter-spacing: -0.02em; }
.word-arrow { color: var(--accent); font-size: 18px; font-weight: 700; }
.word-es { font-size: clamp(17px, 4vw, 24px); color: var(--muted); font-weight: 500; }
.word-index { font-size: 11px; color: var(--muted); margin-top: 8px; }

/* ── Player controls ── */
.player {
  background: var(--bg-alt);
  border-radius: 14px;
  padding: 20px 22px 18px;
  margin-top: 28px;
  border: 1.5px solid var(--border);
}
.progress-wrap { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.progress-track { flex: 1; height: 5px; background: var(--border); border-radius: 50px; overflow: hidden; cursor: pointer; }
.progress-bar { height: 100%; background: var(--primary); width: 0%; border-radius: 50px; transition: width .08s ease-out; }
.progress-time { font-size: 12px; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 30px; }
#progress-elapsed { text-align: right; }
#progress-total   { text-align: left; opacity: 0.55; }

.player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

/* Play button */
.btn-play {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--primary); border: none; border-radius: 10px;
  color: #fff; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 700;
  padding: 11px 22px;
  transition: background .15s, transform .1s;
  letter-spacing: -.01em; flex-shrink: 0;
}
.btn-play:hover  { background: #2a2a2a; }
.btn-play:active { transform: scale(.98); }

/* Prev / Next skip buttons */
.ctrl-skip {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex-shrink: 0;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 10px; cursor: pointer; color: var(--primary);
  transition: background .15s, border-color .15s, transform .1s;
}
.ctrl-skip svg { width: 15px; height: 15px; }
.ctrl-skip:hover  { background: #ebebeb; border-color: #bbb; }
.ctrl-skip:active { transform: scale(.94); }

/* Speed / Loop pills */
.player-pills { display: flex; gap: 6px; margin-left: auto; }
.ctrl-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 8px; color: var(--muted); cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 600;
  padding: 7px 11px; transition: all .15s;
}
.ctrl-pill:hover  { background: var(--bg-alt); color: var(--primary); border-color: #bbb; }
.ctrl-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* btn overrides inside player */
.player .btn { background: var(--bg); border-color: var(--border); color: var(--primary); }
.player .btn:hover { background: #ebebeb; }

.info-row { display: flex; gap: 20px; margin-top: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.loop-on { color: var(--accent); font-weight: 500; }
.pulse-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: currentColor; margin-right: 5px; animation: pulse 1.4s infinite; vertical-align: middle; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.2} }

/* ── Add sentences ── */
.add-section { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.add-form { display: none; margin-top: 16px; }
.add-form.visible { display: block; }

/* ── Alerts ── */
.alert { padding: 11px 14px; margin-bottom: 14px; font-size: 13px; border: 1.5px solid; border-radius: 8px; display: none; }
.alert.visible { display: block; }
.alert-error   { border-color: rgba(220,38,38,0.3);  color: #b91c1c; background: rgba(220,38,38,0.05); }
.alert-success { border-color: rgba(22,163,74,0.3);  color: #15803d; background: rgba(22,163,74,0.05); }

/* ── Skeleton loader ── */
.skeleton-wrap { display: none; margin-top: 40px; }
.skeleton-wrap.visible { display: block; }
.skeleton { background: var(--bg-alt); border: 1.5px solid var(--border); border-radius: 8px; padding: 18px 20px; margin-bottom: 10px; }
.sk-line { height: 10px; background: var(--border); border-radius: 50px; margin-bottom: 9px; animation: shimmer 1.4s infinite; }
.sk-line.short  { width: 35%; }
.sk-line.medium { width: 65%; }
.sk-line.full   { width: 100%; }
@keyframes shimmer { 0%,100%{opacity:1} 50%{opacity:.4} }

.processing-msg { font-size: 13px; color: var(--muted); margin-bottom: 16px; display: none; }
.processing-msg.visible { display: block; }

/* ── Download row ── */
.download-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.voice-picker { display: flex; align-items: center; gap: 6px; flex: 1; }
.voice-label  { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Voice pill buttons — override underline tab style */
.voice-picker .seg-tab {
  border: 1.5px solid var(--border);
  border-bottom: 1.5px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0;
  padding: 5px 9px;
  font-size: 12px;
  background: var(--bg);
  color: var(--muted);
}
.voice-picker .seg-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}
.voice-picker .seg-tab:hover:not(.active) { background: #ebebeb; color: var(--primary); }

/* ── Download message ── */
.download-msg {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: none;
}
.download-msg.visible { display: block; }
.download-msg.error   { color: #b91c1c; border-color: rgba(220,38,38,0.3); background: rgba(220,38,38,0.05); }

/* ── Icon glyph (monochrome filter for emojis) ── */
.icon-glyph {
  display: inline-block;
  filter: grayscale(1) brightness(0.12);
}

/* ── Lucide SVG sizing ── */
.lesson-icon-btn svg { width: 20px; height: 20px; }
.lesson-title-icon svg { width: 26px; height: 26px; }
.icon-picker-emoji svg { width: 18px; height: 18px; }

/* ── Lesson icon ── */
.lesson-icon-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  border-radius: 8px; font-size: 20px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
  padding: 0;
}
.lesson-icon-btn:hover { background: var(--bg-alt); }
.lesson-icon-empty { font-size: 13px; color: #ccc; font-weight: 700; }

.lesson-title-wrap { display: flex; align-items: center; gap: 10px; }
.lesson-title-icon { font-size: 30px; line-height: 1; flex-shrink: 0; }

/* ── Icon picker ── */
.icon-picker {
  position: fixed;
  z-index: 999;
  display: none;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  width: 330px;
  padding: 12px 14px 10px;
}
.icon-picker-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.icon-picker-title { font-size: 12px; font-weight: 700; color: var(--primary); letter-spacing: .05em; text-transform: uppercase; }
.icon-picker-close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px; padding: 2px 6px;
  border-radius: 6px; transition: background .12s;
}
.icon-picker-close:hover { background: var(--bg-alt); color: var(--primary); }

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  margin-bottom: 8px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.icon-picker-grid::-webkit-scrollbar { width: 4px; }
.icon-picker-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.icon-picker-emoji {
  background: none; border: none; cursor: pointer;
  font-size: 18px; padding: 3px; border-radius: 6px;
  aspect-ratio: 1; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .1s, transform .1s;
}
.icon-picker-emoji:hover { background: var(--bg-alt); transform: scale(1.2); }

.icon-picker-none {
  width: 100%; padding: 7px; background: none;
  border: 1.5px dashed var(--border); border-radius: 8px;
  font-family: 'Inter', sans-serif; font-size: 12px;
  color: var(--muted); cursor: pointer; font-weight: 500;
  transition: border-color .12s, color .12s;
}
.icon-picker-none:hover { border-color: var(--primary); color: var(--primary); }

/* ── Habit tracker ── */
.habit-card {
  background: var(--bg-alt);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px 16px;
  margin-bottom: 32px;
}
.habit-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}
.habit-title { font-size: 12px; font-weight: 700; color: var(--primary); letter-spacing: .06em; text-transform: uppercase; }
.habit-stats { display: flex; align-items: center; gap: 0; }
.habit-stat {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; flex: 1; padding: 4px 6px;
}
.habit-stat-num {
  font-size: 28px; font-weight: 800; color: var(--primary);
  letter-spacing: -.04em; line-height: 1; flex-shrink: 0;
}
.habit-stat-label {
  font-size: 11px; color: var(--muted); font-weight: 500;
  line-height: 1.35; text-align: left; max-width: 62px;
}
.habit-stat-sep { width: 1px; height: 36px; background: var(--border); flex-shrink: 0; }

/* Cuarto contador: vocabulario. Es un enlace al listado de palabras. */
.habit-stat-link { text-decoration: none; border-radius: 10px; transition: background .15s; }
.habit-stat-link:hover { background: var(--bg-alt); }
html.dark .habit-stat-link:hover { background: rgba(255,255,255,.04); }
.habit-stat-strong { color: var(--accent); font-weight: 700; }

/* Con cuatro contadores la fila se aprieta. En pantallas estrechas pasa a 2×2,
   con la letra más chica y más aire entre filas, en vez de encoger los números
   hasta hacerlos ilegibles. */
@media (max-width: 767px) {
  .habit-stats { flex-wrap: wrap; row-gap: 20px; }
  .habit-stats > .habit-stat { flex: 0 0 calc(50% - 0.5px); padding: 2px 6px; gap: 9px; }
  /* Los hijos van stat, sep, stat, sep, stat, sep, stat: el cuarto es el
     separador central, y ocultarlo es lo que parte las dos filas limpiamente. */
  .habit-stats > :nth-child(4) { display: none; }
  .habit-stat-num   { font-size: 21px; }
  .habit-stat-label { font-size: 10.5px; line-height: 1.3; max-width: 80px; }
  .habit-stat-sep   { height: 30px; }
}

.hm-scroll { overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.hm-scroll::-webkit-scrollbar { display: none; }

/* ── Trend chart ── */
.trend-section { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px; }
.trend-title { font-size: 11px; font-weight: 700; color: #555; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }
.trend-sub { font-weight: 400; color: #bbb; text-transform: none; letter-spacing: 0; }
.trend-chart-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.trend-chart-wrap::-webkit-scrollbar { display: none; }
.trend-chart-inner { min-width: 560px; height: 90px; }

.hm-months-row { display: flex; margin-bottom: 3px; }
.hm-day-spacer { width: 20px; flex-shrink: 0; }
.hm-months     { position: relative; height: 13px; flex: 1; min-width: 0; }
.hm-month-label { position: absolute; font-size: 10px; color: var(--muted); font-weight: 500; white-space: nowrap; top: 0; }

.hm-body { display: flex; gap: 4px; align-items: flex-start; }
.hm-days {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  gap: 2px;
  width: 16px;
  flex-shrink: 0;
}
.hm-day-label { font-size: 9px; color: var(--muted); display: flex; align-items: center; justify-content: flex-end; padding-right: 2px; }

.hm-grid {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 2px;
}
.hm-cell { border-radius: 2px; }
.hm-cell[data-level="0"] { background: #e8e8e8; }
.hm-cell[data-level="1"] { background: #bbf7d0; }
.hm-cell[data-level="2"] { background: #4ade80; }
.hm-cell[data-level="3"] { background: var(--accent); }
.hm-future { background: #f2f2f2; }

/* GitHub dark mode contribution colors */
html.dark .hm-cell[data-level="0"] { background: #21262d; }
html.dark .hm-cell[data-level="1"] { background: #0e4429; }
html.dark .hm-cell[data-level="2"] { background: #26a641; }
html.dark .hm-cell[data-level="3"] { background: #39d353; }
html.dark .hm-future               { background: #161b22; }

/* ── Day history modal ── */
.day-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  padding: 20px;
}
.day-modal-panel {
  background: var(--card);
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}
.day-modal-head {
  padding: 20px 20px 0;
  flex-shrink: 0;
}
.day-modal-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
}
.day-modal-date {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}
.day-modal-mins {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}
.day-modal-list {
  border-top: 1px solid var(--border);
  flex: 1;
  overflow-y: auto;
}
.day-modal-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
}
.day-modal-time  { font-size: 12px; color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; min-width: 36px; }
.day-modal-name  { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-modal-score { font-size: 12px; font-weight: 700; color: var(--accent); flex-shrink: 0; background: rgba(63,185,80,.12); padding: 2px 8px; border-radius: 20px; }
.day-modal-footer {
  padding: 16px 20px;
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}
.day-modal-footer button { min-width: 80px; }

/* ══ Evaluación automática (quiz.js) ══════════════════════════════════════ */

.quiz-overlay {
  position: fixed; inset: 0; z-index: 1060;
  /* Oscuro Y desenfocado. Con el 45% de antes la práctica se seguía leyendo
     detrás, y la práctica es donde está la respuesta: en «ordena la frase» se
     veía la frase entera a la izquierda del ejercicio. El desenfoque es lo que
     de verdad impide leer —bajar la opacidad solo apaga—, y el negro queda por
     si el navegador no lo soporta. */
  background: rgba(0,0,0,.82);
  -webkit-backdrop-filter: blur(7px);
          backdrop-filter: blur(7px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; transition: opacity .18s ease;
}
.quiz-overlay.visible { opacity: 1; }

.quiz-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%; max-width: 520px;
  /* Altura FIJA, no max-height: si la caja creciera con el contenido de cada
     ejercicio, el pie con los botones saltaría entre un ítem y el siguiente.
     El cuerpo absorbe la diferencia con su propio scroll. */
  height: 90vh;              /* respaldo para navegadores sin dvh */
  height: 90dvh;
  display: flex; flex-direction: column;
  box-shadow: 0 12px 48px rgba(0,0,0,.22);
  transform: translateY(8px) scale(.99);
  transition: transform .18s ease;
}
.quiz-overlay.visible .quiz-card { transform: none; }
html.dark .quiz-card { box-shadow: 0 12px 48px rgba(0,0,0,.6); }

/* ── Cabecera: progreso ── */
.quiz-head {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.quiz-progress { flex: 1; height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; }
.quiz-progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .3s ease; }
.quiz-count { font-size: 12px; font-weight: 600; color: var(--muted); min-width: 38px; text-align: right; }
.quiz-close {
  width: 28px; height: 28px; flex-shrink: 0;
  border: none; background: transparent; color: var(--muted);
  border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.quiz-close:hover { background: var(--bg-alt); color: var(--text); }
.quiz-close svg { width: 15px; height: 15px; }

/* ── Cuerpo ── */
.quiz-body { padding: 24px 22px; overflow-y: auto; flex: 1; }
.quiz-kicker {
  font-size: 11px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 14px;
}
.quiz-hint { font-size: 13.5px; color: var(--muted); line-height: 1.5; margin-bottom: 16px; }

/* Frase con hueco */
.quiz-sentence {
  font-size: 16px; line-height: 2; color: var(--text);
  margin-bottom: 16px; word-break: break-word;
}
.quiz-word  { margin-right: 6px; }
.quiz-blank {
  display: inline-block; margin-right: 6px; padding: 0 8px;
  color: var(--accent); font-weight: 700; letter-spacing: .06em;
  border-bottom: 2px solid var(--accent);
}
.quiz-bigword {
  font-size: 26px; font-weight: 700; letter-spacing: -.03em;
  color: var(--text); margin-bottom: 20px; word-break: break-word;
}

/* Pista + campo pegados al fondo del área desplazable: la frase puede
   desplazarse, pero el significado y el input nunca se van de la vista cuando
   sube el teclado. El fondo opaco evita que el texto se transparente detrás. */
.quiz-pinned {
  position: sticky; bottom: 0;
  background: var(--card);
  padding-top: 12px;
  margin-top: 8px;
}
.quiz-pinned::before {
  content: ''; position: absolute; left: 0; right: 0; top: -18px; height: 18px;
  background: linear-gradient(to bottom, transparent, var(--card));
  pointer-events: none;
}
.quiz-pinned .quiz-hint { margin-bottom: 10px; }

.quiz-input {
  width: 100%; padding: 14px 16px;
  background: var(--bg-alt);
  border: 2px solid transparent; border-radius: 12px;
  color: var(--text); font-family: 'Inter', sans-serif; font-size: 16px;
  outline: none; -webkit-appearance: none;
  transition: border-color .15s;
}
.quiz-input:focus { border-color: var(--accent); }
.quiz-input::placeholder { color: var(--muted); opacity: .7; }

/* Opción múltiple */
.quiz-options { display: flex; flex-direction: column; gap: 9px; }
.quiz-option {
  width: 100%; text-align: left;
  padding: 14px 16px; border-radius: 12px;
  border: 2px solid var(--border); background: var(--bg);
  color: var(--text); font-family: 'Inter', sans-serif;
  font-size: 15px; font-weight: 500; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.quiz-option:hover    { border-color: var(--muted); }
.quiz-option.selected { border-color: var(--accent); background: rgba(22,163,74,.08); font-weight: 600; }
html.dark .quiz-option          { background: transparent; }
html.dark .quiz-option.selected { background: rgba(63,185,80,.10); }

/* Ordenar la frase */
.quiz-slot {
  min-height: 58px; padding: 10px;
  border: 2px dashed var(--border); border-radius: 12px;
  display: flex; flex-wrap: wrap; gap: 7px; align-content: flex-start;
  margin-bottom: 14px;
}
.quiz-slot-empty { font-size: 13px; color: var(--muted); align-self: center; padding: 6px; }
.quiz-bank { display: flex; flex-wrap: wrap; gap: 7px; }
.quiz-chip {
  padding: 9px 13px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--bg);
  color: var(--text); font-family: 'Inter', sans-serif;
  font-size: 14.5px; font-weight: 500; cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.quiz-chip:hover  { border-color: var(--muted); }
.quiz-chip:active { transform: scale(.96); }
.quiz-chip.is-chosen { border-color: var(--accent); background: rgba(22,163,74,.08); }
html.dark .quiz-chip            { background: transparent; }
html.dark .quiz-chip.is-chosen  { background: rgba(63,185,80,.10); }

/* Corrección */
.quiz-feedback { margin-top: 18px; padding: 14px 16px; border-radius: 12px; border: 1px solid; }
.quiz-feedback-title { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.quiz-feedback-sol   { font-size: 14px; font-weight: 500; opacity: .85; }
.quiz-feedback.is-ok      { background: rgba(22,163,74,.09);  border-color: rgba(22,163,74,.28);  color: #15803d; }
.quiz-feedback.is-partial { background: rgba(217,119,6,.09);  border-color: rgba(217,119,6,.28);  color: #b45309; }
.quiz-feedback.is-bad     { background: rgba(220,38,38,.07);  border-color: rgba(220,38,38,.24);  color: #b91c1c; }
html.dark .quiz-feedback.is-ok      { color: #56d364; }
html.dark .quiz-feedback.is-partial { color: #e3b341; }
html.dark .quiz-feedback.is-bad     { color: #f85149; }

/* Resultado */
.quiz-result-ring {
  width: 108px; height: 108px; border-radius: 50%; margin: 6px auto 20px;
  display: flex; align-items: center; justify-content: center;
  border: 6px solid var(--border);
}
.quiz-result-ring.is-high { border-color: var(--accent); }
.quiz-result-ring.is-mid  { border-color: #d97706; }
.quiz-result-ring.is-low  { border-color: var(--red); }
.quiz-result-pct   { font-size: 27px; font-weight: 800; letter-spacing: -.04em; color: var(--text); }
.quiz-result-title { font-size: 18px; font-weight: 700; text-align: center; color: var(--text); letter-spacing: -.02em; }
.quiz-result-sub   { font-size: 14px; color: var(--muted); text-align: center; margin-top: 5px; }

.quiz-note {
  margin-top: 18px; padding: 12px 15px; border-radius: 12px;
  background: rgba(22,163,74,.08); border: 1px solid rgba(22,163,74,.22);
  font-size: 13.5px; font-weight: 500; line-height: 1.55; color: var(--text);
  text-align: center;
}
html.dark .quiz-note { background: rgba(63,185,80,.08); border-color: rgba(63,185,80,.24); }

.quiz-review { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 16px; }
.quiz-review-head {
  font-size: 11px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
}
.quiz-review-row {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.quiz-review-row:last-child { border-bottom: none; }
.quiz-review-q { color: var(--muted); flex: 1; min-width: 0; }
.quiz-review-a { color: var(--text); font-weight: 600; text-align: right; flex-shrink: 0; max-width: 55%; }

/* ── Las tarjetas de plan ────────────────────────────────────────────────────
   Un solo diseño para los dos sitios donde hay que elegir: el cuadro que sale
   al chocar con el muro y la página de Mi plan. Es el mismo de la portada —
   precio grande, lo que incluye con su palomita, y el botón abajo— porque es
   la misma decisión, y verla distinta en cada sitio hace dudar de cuál manda. */
.planes-rejilla {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; align-items: stretch;
}
.plan-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 26px 22px; box-shadow: var(--shadow);
}
.plan-card.destacado { border-color: var(--accent); border-width: 1.5px; }
.plan-card.es-tuyo   { border-color: var(--accent); border-width: 1.5px; }
.plan-tag {
  position: absolute; top: -11px; left: 22px;
  /* El verde de marca con blanco encima da 3.3:1, y esto son diez pixeles en
     mayusculas: justo lo que peor se lee. Oscurecido queda en 5.1 y sigue
     siendo el mismo verde. En oscuro el texto es el fondo de la pagina, que
     ahi ya da 7.4. */
  background: color-mix(in srgb, var(--accent) 78%, #000);
  color: #fff; font-size: 10.5px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; padding: 4px 11px; border-radius: 20px;
  white-space: nowrap;
}
html.dark .plan-tag { background: var(--accent); color: #0d1117; }
.plan-card-n { font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.plan-card-p { font-size: 34px; font-weight: 800; letter-spacing: -.045em; margin: 12px 0 2px; }
.plan-card-p small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.plan-card-eq { font-size: 12.5px; color: var(--muted); min-height: 18px; }
.plan-card ul { list-style: none; margin: 18px 0 22px; padding: 0; display: grid; gap: 9px; flex: 1; }
.plan-card li { display: flex; gap: 9px; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.plan-card li svg { width: 15px; height: 15px; color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.plan-card li b { color: var(--text); font-weight: 600; }
.plan-card .btn {
  width: 100%; box-sizing: border-box; text-align: center;
  padding: 11px 18px; font-size: 13.5px;
}
.plan-card-tuyo {
  text-align: center; font-size: 13px; font-weight: 700; color: var(--accent);
  padding: 11px; border: 1px solid var(--accent); border-radius: 12px;
}

@media (max-width: 1100px) { .planes-rejilla { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px)  { .planes-rejilla { grid-template-columns: 1fr; } }

/* ── Pie ── */
.quiz-foot {
  display: flex; gap: 10px; align-items: center;
  padding: 16px 20px; border-top: 1px solid var(--border);
}
.quiz-audio {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 12px 15px; border-radius: 12px;
  border: 1.5px solid var(--border); background: transparent;
  color: var(--text); font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 500; cursor: pointer; flex-shrink: 0;
}
.quiz-audio:hover { border-color: var(--accent); color: var(--accent); }
.quiz-audio svg   { width: 15px; height: 15px; }
/* Saltar es una salida, no una acción principal: se ve, pero no compite con
   Comprobar. Sin borde y en gris se lee como «no puedo con esta». */
.quiz-skip {
  padding: 12px 14px; border-radius: 12px;
  border: none; background: transparent;
  color: var(--muted); font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 600; cursor: pointer; flex-shrink: 0;
  transition: color .15s, background .15s;
}
.quiz-skip:hover { color: var(--text); background: var(--bg-alt); }
.quiz-skip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.quiz-review-skip {
  margin-left: 7px; padding: 1px 6px; border-radius: 999px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: var(--bg-alt);
}

.quiz-main {
  flex: 1; padding: 13px; border-radius: 12px; border: none;
  background: var(--accent); color: #fff;
  font-family: 'Inter', sans-serif; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: opacity .15s;
}
.quiz-main:hover    { opacity: .9; }
.quiz-main:disabled { opacity: .45; cursor: not-allowed; }
.quiz-main.shake    { animation: quizShake .32s ease; }
@keyframes quizShake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-5px); }
  75%      { transform: translateX(5px); }
}

@media (max-width: 560px) {
  .quiz-overlay { padding: 0; align-items: flex-end; }
  .quiz-card {
    max-width: 100%; border-radius: 20px 20px 0 0;
    /* Misma altura fija que en escritorio: la hoja sube hasta el 90% de la
       pantalla y se queda ahí, en vez de crecer y encoger con cada ejercicio. */
    height: 90vh;
    height: 90dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .quiz-bigword { font-size: 23px; }
  .quiz-audio span { display: none; }
  .quiz-audio { padding: 13px; }
  /* Con el icono de audio y Comprobar, «Saltar» entero dejaba al principal en
     dos palabras por línea. */
  .quiz-skip { padding: 13px 8px; font-size: 13px; }
}

/* ── Comprehension prompt ── */
.comp-prompt {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: rgba(0,0,0,0.32);
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.comp-prompt.visible { display: flex; animation: cfFade .15s ease; }
.comp-prompt-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 20px;
  padding: 28px 24px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 8px 48px rgba(0,0,0,0.14);
  animation: cfSlide .15s ease;
}
.comp-prompt-icon {
  width: 44px; height: 44px;
  background: #f0fdf4; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.comp-prompt-icon svg { width: 20px; height: 20px; stroke: var(--accent); stroke-width: 1.75; }

.comp-prompt-title { font-size: 16px; font-weight: 700; color: #111; margin-bottom: 6px; letter-spacing: -.02em; }
.comp-prompt-sub   { font-size: 14px; color: #888; line-height: 1.5; margin-bottom: 20px; }

.comp-scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; margin-bottom: 8px; }
.comp-btn {
  width: 100%; height: 38px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--primary);
  font-family: 'Inter', sans-serif;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.comp-btn:hover:not(:disabled) { border-color: var(--score-color, var(--primary)); color: var(--score-color, var(--primary)); transform: scale(1.08); }
.comp-btn.selected { background: var(--score-color, var(--primary)); border-color: var(--score-color, var(--primary)); color: #fff; }
.comp-btn:disabled:not(.selected) { opacity: .3; cursor: not-allowed; transform: none; }

.comp-scale-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); padding: 0 2px; margin-bottom: 4px; }

.comp-saved { display: none; font-size: 13px; color: var(--accent); font-weight: 600; margin-top: 14px; }
.comp-saved.visible { display: block; animation: fadeUp .2s ease; }
.comp-saved--motivation {
  font-size: 13px; font-weight: 500; line-height: 1.55;
  background: #f0fdf4; border-radius: 10px; padding: 10px 14px;
  border: 1px solid #bbf7d0; color: #166534;
}

/* ── Comprehension history ── */
.comp-history {
  display: none;
  background: var(--bg-alt);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  margin-top: 16px;
}
.comp-history.visible { display: block; }

.comp-history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.comp-history-title  { font-size: 13px; font-weight: 700; color: var(--primary); letter-spacing: -.01em; }
.comp-history-sub    { font-size: 11px; color: var(--muted); margin-top: 2px; }
.comp-avg            { font-size: 12px; color: var(--muted); font-weight: 500; }

.comp-chart-wrap { position: relative; height: 160px; }
.comp-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 16px 0; line-height: 1.6; }

/* ═══════════════════════════════════════════════════════════════════════════
   FROM index.php <style> block
   ═══════════════════════════════════════════════════════════════════════════ */

.confirm-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(0,0,0,0.32);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: cfFade .15s ease;
}
@keyframes cfFade { from { opacity: 0 } to { opacity: 1 } }
.confirm-card {
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 20px;
  padding: 32px 28px 24px;
  max-width: 360px; width: 100%;
  box-shadow: 0 8px 48px rgba(0,0,0,0.14);
  animation: cfSlide .15s ease;
}
@keyframes cfSlide { from { transform: translateY(10px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }
.confirm-icon {
  width: 44px; height: 44px;
  background: #fef2f2; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 16px;
}
.confirm-icon svg { width: 20px; height: 20px; stroke: #dc2626; stroke-width: 1.75; }
.confirm-title {
  font-size: 16px; font-weight: 700; color: #111;
  letter-spacing: -.02em; margin-bottom: 6px;
}
.confirm-body {
  font-size: 14px; color: #888; line-height: 1.5; margin-bottom: 24px;
}
.confirm-actions { display: flex; gap: 8px; }
.confirm-btn {
  flex: 1; padding: 11px 0;
  border: 1.5px solid transparent; border-radius: 10px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s, transform .1s;
  letter-spacing: -.01em;
}
.confirm-btn:active { transform: scale(.98); }
.confirm-cancel { background: #f5f5f5; color: #555; border-color: #e5e5e5; }
.confirm-cancel:hover { background: #ebebeb; }
.confirm-ok    { background: #dc2626; color: #fff; }
.confirm-ok:hover { background: #b91c1c; }
.confirm-icon-neutral { background: #f5f5f5; }
.confirm-icon-neutral svg { stroke: #555; }
.confirm-ok-neutral { background: var(--primary); color: #fff; border-color: var(--primary); }
.confirm-ok-neutral:hover { background: #2a2a2a; }

/* ── Intro modal ── */
.intro-card { max-width: 460px; }
.intro-icon-wrap {
  width: 52px; height: 52px; background: #f0fdf4; border-radius: 16px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 18px;
}
.intro-icon-wrap svg { width: 24px; height: 24px; stroke: var(--accent); stroke-width: 1.75; }
.intro-tagline { font-size: 13px; color: #888; margin: 0 0 20px; }
.intro-steps { display: flex; flex-direction: column; gap: 16px; margin-bottom: 24px; }
.intro-step { display: flex; align-items: flex-start; gap: 14px; }
.intro-step-num {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.intro-step-body { display: flex; flex-direction: column; gap: 3px; }
.intro-step-body strong { font-size: 14px; font-weight: 600; color: #111; letter-spacing: -.01em; }
.intro-step-body span { font-size: 13px; color: #888; line-height: 1.45; }
.intro-start-btn { width: 100%; font-size: 15px; padding: 14px; background: var(--accent); color: #fff; border-color: var(--accent); }
.intro-start-btn:hover { background: #15803d; }

/* ── Science section ── */
.science-section {
  margin-top: 56px; padding-top: 40px;
  border-top: 1px solid var(--border);
}
.science-eyebrow {
  font-size: 11px; font-weight: 700; color: var(--accent);
  letter-spacing: .10em; text-transform: uppercase; margin-bottom: 8px;
}
.science-title {
  font-size: 22px; font-weight: 700; color: var(--primary);
  letter-spacing: -.03em; line-height: 1.2; margin-bottom: 6px;
}
.science-subtitle {
  font-size: 14px; color: var(--muted); margin-bottom: 28px; line-height: 1.5;
}

/* Facts */
.facts-scroll {
  display: flex; gap: 12px; overflow-x: auto;
  padding-bottom: 4px; margin-bottom: 32px;
  margin-left: -20px; padding-left: 20px;
  margin-right: -20px; padding-right: 20px;
  scrollbar-width: none;
}
.facts-scroll::-webkit-scrollbar { display: none; }
.fact-card {
  flex-shrink: 0; width: 200px;
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px 16px;
}
.fact-label {
  font-size: 10px; font-weight: 700; color: var(--accent);
  letter-spacing: .09em; text-transform: uppercase; margin-bottom: 10px;
}
.fact-stat {
  font-size: 30px; font-weight: 800; color: var(--primary);
  letter-spacing: -.04em; line-height: 1; margin-bottom: 8px;
}
.fact-text { font-size: 12px; color: var(--muted); line-height: 1.55; }

/* FAQ */
.faq-list { display: flex; flex-direction: column; margin-bottom: 32px; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item:first-child { border-top: 1px solid var(--border); }
.faq-item summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 0;
  font-size: 14px; font-weight: 600; color: var(--primary);
  user-select: none; gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-icon {
  flex-shrink: 0; width: 22px; height: 22px;
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 300; color: var(--muted);
  transition: background .15s;
}
.faq-item[open] .faq-icon { background: var(--primary); color: #fff; border-color: var(--primary); }
.faq-item[open] .faq-icon::before { content: '−'; }
.faq-icon::before { content: '+'; }
.faq-body {
  font-size: 13px; color: var(--muted); line-height: 1.7;
  padding-bottom: 18px;
}
.faq-body strong { color: var(--primary); font-weight: 600; }

/* Metaphor card */
.metaphor-card {
  border: 1.5px solid var(--border); border-radius: 16px;
  padding: 24px 22px; margin-bottom: 32px;
  position: relative; overflow: hidden;
}
.metaphor-card::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--primary);
}
.metaphor-label {
  font-size: 10px; font-weight: 700; color: var(--muted);
  letter-spacing: .10em; text-transform: uppercase; margin-bottom: 12px;
}
.metaphor-text {
  font-size: 14px; color: var(--primary); line-height: 1.75;
}
.metaphor-text strong { font-weight: 700; }

/* Motivation */
.motivation-card {
  background: var(--primary); color: #fff;
  border-radius: 18px; padding: 32px 28px;
  text-align: center; margin-bottom: 16px;
}
.motivation-quote {
  font-size: 17px; font-weight: 600; line-height: 1.55;
  letter-spacing: -.02em; margin-bottom: 14px;
}
.motivation-sub {
  font-size: 11px; color: rgba(255,255,255,0.4);
  letter-spacing: .08em; text-transform: uppercase; font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FROM new.php <style> block
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Story browser ── */
.story-search {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  outline: none;
  transition: border-color .15s;
  margin-bottom: 16px;
}
.story-search:focus { border-color: var(--primary); }
.story-search::placeholder { color: #ccc; }

.topic-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}
.filter-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.topic-pill {
  background: none;
  border: 1.5px solid var(--border);
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 50px;
  cursor: pointer;
  transition: all .15s;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.topic-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.topic-pill:hover:not(.active) { border-color: #aaa; color: var(--primary); }
.diff-pill { border-radius: 50px; }
.diff-pill.active-baja   { background: #16a34a; border-color: #16a34a; color: #fff; }
.diff-pill.active-media  { background: #d97706; border-color: #d97706; color: #fff; }
.diff-pill.active-alta   { background: #dc2626; border-color: #dc2626; color: #fff; }
.diff-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 50px;
}
.diff-badge.Baja,  .diff-badge.BAJA  { background: rgba(22,163,74,.12);  color: #15803d; }
.diff-badge.Media, .diff-badge.MEDIA { background: rgba(217,119,6,.12);  color: #b45309; }
.diff-badge.Alta,  .diff-badge.ALTA  { background: rgba(220,38,38,.12);  color: #b91c1c; }

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
  padding: 3px 4px 0 2px;
}
.story-grid::-webkit-scrollbar { width: 4px; }
.story-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.story-card {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s, box-shadow .15s;
  background: var(--bg);
  position: relative;
  height: 210px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.story-card:hover { border-color: #bbb; background: var(--bg-alt); transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.07); }
.story-card.selected { border-color: var(--accent); background: rgba(22,163,74,0.05); box-shadow: 0 0 0 3px rgba(22,163,74,.08); }
.story-card.saved { border-color: #86efac; background: #f0fdf4; }
.story-card.saved:hover { border-color: #4ade80; background: #dcfce7; }
.story-saved-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600; color: #16a34a; background: #dcfce7; border: 1px solid #86efac; border-radius: 20px; padding: 3px 9px; margin-left: auto; }

.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.story-topic-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-alt);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 22px;
  line-height: 1;
}
.story-topic-icon svg {
  width: 22px;
  height: 22px;
  color: var(--primary);
  display: block;
}
.story-selected-check {
  display: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
  background: rgba(22,163,74,0.12);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.story-card.selected .story-selected-check { display: flex; }

.story-country { font-size: 11px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.story-title { font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 6px; line-height: 1.35; }
.story-preview {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  font-style: italic;
  flex: 1;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}
.story-bottom {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-shrink: 0;
  overflow: hidden;
  min-width: 0;
}
.story-id {
  font-size: 10px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  color: var(--muted);
  letter-spacing: .04em;
  margin-right: auto;
}
.story-card.selected .story-id { color: var(--accent); }
.story-words {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  margin-left: auto;
  white-space: nowrap;
}
.story-saves {
  font-size: 10px;
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
}
.story-topic {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.story-bottom .diff-badge { margin-top: 0; }

.no-stories { text-align: center; padding: 40px 0; color: var(--muted); font-size: 14px; }

.title-with-icon { display: flex; align-items: center; gap: 8px; }
.title-with-icon input { flex: 1; }

.selected-story-bar {
  display: none;
  align-items: center;
  gap: 12px;
  background: rgba(22,163,74,0.06);
  border: 1.5px solid rgba(22,163,74,0.3);
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 13px;
}
/* Bar fija al fondo cuando hay selección */
.selected-story-bar.visible {
  display: flex !important;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  margin: 0;
  border-radius: 0;
  border-left: none; border-right: none; border-bottom: none;
  border-top: 1.5px solid rgba(22,163,74,.3);
  background: rgba(243,254,248,.97);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 -4px 24px rgba(0,0,0,.10);
  z-index: 300;
  padding: 12px 20px;
}
.selected-story-bar strong { color: var(--primary); }
.selected-story-bar > span:nth-child(3) { flex: 1; }   /* name span grows */
.btn-clear-story { color: var(--muted); background: none; border: none; cursor: pointer; font-size: 18px; padding: 0 4px; flex-shrink: 0; }
.btn-clear-story:hover { color: var(--red); }
.selected-bar-icon { display: flex; align-items: center; flex-shrink: 0; }
.selected-bar-icon svg { width: 16px; height: 16px; color: var(--accent); }
.bar-start-btn { flex-shrink: 0; padding: 8px 18px; font-size: 13px; }

/* ── Story modal ── */
.story-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.story-modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.story-modal-panel {
  background: #fff;
  border-radius: 16px;
  max-width: 560px;
  width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.18);
  transform: translateY(16px) scale(0.98);
  transition: transform .22s;
}
.story-modal-panel::-webkit-scrollbar { width: 4px; }
.story-modal-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.story-modal-overlay.open .story-modal-panel { transform: translateY(0) scale(1); }

.modal-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.modal-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--bg-alt);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.modal-icon-wrap svg {
  width: 28px;
  height: 28px;
  color: var(--primary);
  display: block;
}
.modal-meta { flex: 1; }
.modal-flag-country {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 5px;
}
.modal-flag-country span:first-child { font-size: 16px; }
.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.3;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.modal-summary {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  font-style: italic;
  background: var(--bg-alt);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.modal-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 0 16px;
}
.modal-text-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.modal-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.8;
  white-space: pre-wrap;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  justify-content: flex-end;
}

/* ═══════════════════════════════════════════════════════════════════════════
   #card-word layout rule (replaces inline style in lesson.php)
   ═══════════════════════════════════════════════════════════════════════════ */

#card-word {
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Tablet (768px+) ── */
@media (min-width: 768px) {
  body { padding: 0 32px 80px; }
  .container { max-width: 820px; }

  /* De carrusel a rejilla. Las columnas las decide la página según cuántas
     tarjetas haya, para que no quede ninguna sola en la última fila. */
  .facts-scroll {
    display: grid;
    grid-template-columns: repeat(var(--fact-cols, 3), 1fr);
    overflow-x: visible;
    margin-left: 0; margin-right: 0;
    padding-left: 0; padding-right: 0;
  }
  .fact-card { width: auto; flex-shrink: 1; }

  .story-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); max-height: 500px; }

  .comp-btn { height: 42px; }

  .voice-picker { flex-wrap: nowrap; }
}

/* ── Desktop (1024px+) ── */
@media (min-width: 1024px) {
  body { padding: 0 56px 100px; }
  .container { max-width: 1200px; }

  .nav { margin-bottom: 52px; }
  .nav-username { max-width: 180px; }

  /* Lesson list: 2-column grid */
  .lesson-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--border);
    margin-bottom: 32px;
  }
  .lesson-item { border-top: none !important; }
  .lesson-item:nth-child(odd)  { border-right: 1px solid var(--border); padding-right: 36px; }
  .lesson-item:nth-child(even) { padding-left: 36px; }

  .play-card { padding: 24px 0; }

  .player { padding: 24px 28px 20px; margin-top: 32px; }
  .btn-play { padding: 13px 28px; font-size: 15px; }
  .ctrl-skip { width: 44px; height: 44px; }

  .comp-btn { height: 44px; font-size: 15px; }
  .comp-chart-wrap { height: 200px; }

  .habit-card { padding: 22px 28px 18px; }

  .science-title { font-size: 28px; }

  /* Aquí estaba el desajuste: la rejilla pedía cinco columnas a pelo y las
     tarjetas son seis, así que la sexta se quedaba sola debajo. El reparto lo
     decide ahora la página con --fact-cols. */
  .facts-scroll {
    display: grid;
    grid-template-columns: repeat(var(--fact-cols, 3), 1fr);
    gap: 12px;
    overflow-x: visible;
    margin: 0 0 32px;
    padding: 0;
  }
  .fact-card { width: auto; }

  .story-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    max-height: 560px;
  }
}

/* ── Large desktop (1280px+) ── */
@media (min-width: 1280px) {
  .container { max-width: 1440px; }
  .lesson-item:nth-child(odd)  { padding-right: 52px; }
  .lesson-item:nth-child(even) { padding-left: 52px; }
  .fact-card { padding: 20px 18px; }
  .fact-stat { font-size: 34px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   SPLIT LAYOUT  (index.php — tablet / desktop)
   ═══════════════════════════════════════════════════════════════════════════ */

/* Mobile base — stacked, body padding carries horizontal spacing */
.split-left-inner { padding-top: 32px; }
.split-empty      { padding-top: 24px; }

/* Botón principal de la barra lateral: ocupa todo el ancho disponible y es el
   objetivo táctil más grande de la pantalla, porque es la acción principal. */
.btn.split-new-btn {
  display: block; width: 100%; text-align: center;
  margin-bottom: 20px; padding: 13px 18px;
  font-size: 15px; font-weight: 600; border-radius: 11px;
}

/* En móvil la barra lateral se apila arriba: hay que separarla del borde
   superior de la pantalla, y en la app instalada tambien de la barra de
   estado, que ahi no la aparta ningun navegador. */
@media (max-width: 767px) {
  .split-left-inner { padding-top: calc(30px + env(safe-area-inset-top)); }
  .btn.split-new-btn { padding: 15px 18px; font-size: 16px; }
}

/* Paginas de documento (Mis palabras, Costos, Como cobrar): en movil la lista
   de practicas empujaba el contenido real muy abajo. Se deja solo el menu,
   igual que en la pagina de nueva practica.
   Todo va dentro de .split-left a proposito: sin ese scope, `.lesson-pager`
   cazaba tambien el paginador de las tablas de datos —que usa el mismo
   aspecto— y en movil desaparecian los de Finanzas, Metricas, Mis palabras,
   Mensajes y Usuarios, que es justo donde mas falta hacen. */
@media (max-width: 767px) {
  body.doc-page .split-left .split-list-head,
  body.doc-page .split-left .lesson-list,
  body.doc-page .split-left .lesson-pager,
  body.doc-page .split-left .empty { display: none; }

  body.doc-page .split-left .nav      { margin-bottom: 0; }
  body.doc-page .split-left-inner     { padding-bottom: 0; }
}

/* Habit-card movido al sidebar en mobile */
@media (max-width: 767px) {
  .split-left-inner > .habit-card {
    margin: 0 0 24px;
    border-radius: 14px;
  }
}

/* Hide lesson iframe on mobile */
#lesson-frame { display: none; }

/* On new-practice page: keep nav header, hide list content on mobile */
@media (max-width: 767px) {
  /* Dentro de .split-left, por lo mismo que arriba. */
  body.new-practice-page .split-left .split-list-head,
  body.new-practice-page .split-left .lesson-list,
  body.new-practice-page .split-left .lesson-pager,
  body.new-practice-page .split-left .empty { display: none; }

  body.new-practice-page .split-left .nav { margin-bottom: 0; }
  body.new-practice-page .split-left-inner { padding-bottom: 0; }

  .lesson-pager { padding: 10px 0 24px; gap: 16px; }
  .pager-btn    { width: 38px; height: 38px; font-size: 16px; border-radius: 8px; }

  textarea { resize: none; }
}

@media (min-width: 768px) {
  body.split-page {
    padding: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .split-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
  }

  /* ── Left sidebar ── */
  .split-left {
    width: 300px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  .split-left::-webkit-scrollbar { width: 4px; }
  .split-left::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  .split-left-inner { padding: 24px 20px 60px; }

  .split-left .nav { margin-bottom: 24px; padding-bottom: 16px; }

  .split-list-head { margin-bottom: 6px; }
  .split-left h1   { font-size: 22px; margin-bottom: 4px; }
  .split-left .subtitle { font-size: 12px; margin-bottom: 14px; }
  .split-left .badge    { margin-bottom: 5px; }
  .split-new-btn  { margin-bottom: 16px; width: 100%; display: block; text-align: center; }

  /* Single-column list — override 1024px grid rules */
  .split-left .lesson-list {
    display: flex !important;
    flex-direction: column;
    border-top: none;
    margin-bottom: 0;
    gap: 0;
  }
  .split-left .lesson-item {
    padding: 10px 0 !important;
    border-right: none !important;
    padding-right: 0 !important;
    padding-left: 0 !important;
    border-radius: 0;
    transition: background .12s, border-left .12s;
  }
  .split-left .lesson-title { font-size: 13px; }
  .split-left .lesson-meta  { font-size: 11px; }
  .split-left .lesson-icon-btn { width: 28px; height: 28px; font-size: 16px; }
  .split-left .lesson-icon-btn svg { width: 16px; height: 16px; }

  /* Selected item */
  .lesson-item.is-selected {
    background: rgba(22, 163, 74, 0.06) !important;
    border-left: 3px solid var(--accent) !important;
    padding-left: 6px !important;
  }
  .lesson-item.is-selected .lesson-title { font-weight: 700; color: var(--accent); }

  /* ── Right panel ── */
  .split-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
  }

  .split-empty {
    flex: 1;
    overflow-y: auto;
    padding: 28px 36px 80px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }

  .split-empty .science-section { margin-top: 28px; padding-top: 28px; }

  #lesson-frame {
    display: none;
    flex: 1;
    width: 100%;
    border: none;
    min-height: 0;
  }
  #lesson-frame.active { display: block; }
}

@media (min-width: 1024px) {
  .split-left        { width: 340px; }
  .split-left-inner  { padding: 28px 24px 60px; }
  .split-empty       { padding: 36px 48px 100px; }
}

@media (min-width: 1280px) {
  .split-left        { width: 380px; }
  .split-left-inner  { padding: 32px 28px 60px; }
  .split-empty       { padding: 40px 60px 100px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PANEL MODE  (lesson.php loaded inside iframe)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Player mobile: sticky bottom, compacto ── */
@media (max-width: 767px) {
  /* ── Lesson page header ── */
  .nav { padding-bottom: 12px; margin-bottom: 20px; }
  .nav-brand { font-size: 14px; }
  .nav-username { max-width: 100px; }

  h1 { font-size: clamp(20px, 6vw, 28px); margin-bottom: 6px; }

  .badge { margin-bottom: 5px; }

  .lesson-header {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
  }
  .lesson-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 0;
  }
  .lesson-actions .btn { font-size: 12px; padding: 6px 12px; }

  .subtitle {
    font-size: 12px;
    line-height: 1.6;
    margin-bottom: 4px;
  }
  .subtitle-practice { margin-bottom: 0; font-size: 11px; }

  /* ── Contenido con espacio para el player fijo ── */
  .play-cards { padding-bottom: 8px; }

  /* Player sticky al fondo */
  .player {
    position: sticky;
    bottom: 0;
    margin: 20px -20px 0;
    border-radius: 16px 16px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 14px 16px 24px;
    box-shadow: 0 -6px 24px rgba(0,0,0,.10);
    z-index: 50;
  }

  /* Barra de progreso más compacta */
  .progress-wrap { margin-bottom: 12px; }

  /* Controles: play centrado, pills a los lados sin texto */
  .player-controls { gap: 6px; margin-bottom: 12px; }
  .btn-play { padding: 10px 20px; font-size: 13px; flex: 1; justify-content: center; }
  .ctrl-skip { width: 36px; height: 36px; }
  .ctrl-skip svg { width: 13px; height: 13px; }
  .player-pills { gap: 5px; }
  .ctrl-pill { padding: 7px 10px; }
  .ctrl-pill span { display: none; }          /* ocultar "Bucle" y "1×" */
  #speed-label { display: inline; }           /* solo el número de velocidad */

  /* Acento + banderas: sin label, botones compactos */
  .voice-label { display: none; }
  .voice-picker { gap: 4px; }
  .voice-picker .seg-tab { padding: 4px 7px; font-size: 11px; }

  /* Download row: apilado */
  .download-row { flex-direction: column; gap: 8px; align-items: stretch; }
  #btn-download { width: 100%; display: flex; justify-content: center; }

  /* Info row más compacto */
  .info-row { margin-top: 8px; }

  /* ── Tarjetas de práctica compactas en móvil ── */
  .play-card { padding: 8px 0; }
  .card-label { margin-bottom: 3px; font-size: 10px; }

  .sentence-text { font-size: 13px; line-height: 1.35; }
  .literal-text  { font-size: 12px; line-height: 1.35; }
  .natural-text  { font-size: 12px; line-height: 1.35; }

  .word-pair { gap: 10px; }
  .word-en   { font-size: clamp(18px, 4.5vw, 26px); }
  .word-es   { font-size: clamp(14px, 3.5vw, 20px); }
  .word-arrow { font-size: 15px; }
  .word-index { margin-top: 4px; }
}

body.panel-mode {
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
}
body.panel-mode .nav { display: none; }
body.panel-mode .container {
  max-width: none;
  padding: 24px 24px 24px;
}

/* ── Panel-mode: tarjetas y texto compactos ── */
body.panel-mode .play-card    { padding: 14px 0; }
body.panel-mode .card-label   { margin-bottom: 6px; }
body.panel-mode .sentence-text { font-size: clamp(13px, 1.6vw, 17px); line-height: 1.5; }
body.panel-mode .literal-text  { font-size: clamp(12px, 1.4vw, 14px); line-height: 1.4; }
body.panel-mode .natural-text  { font-size: clamp(12px, 1.4vw, 14px); line-height: 1.4; }
body.panel-mode .word-en  { font-size: clamp(18px, 2.5vw, 26px); }
body.panel-mode .word-es  { font-size: clamp(14px, 2vw, 20px); }
body.panel-mode .word-pair { gap: 14px; }

/* ── Panel-mode: player sticky al fondo, layout compacto en 2 filas ── */
body.panel-mode .play-cards { padding-bottom: 140px; }

body.panel-mode .player {
  position: sticky;
  bottom: 0;
  margin: 0 -24px;
  border-radius: 14px 14px 0 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  padding: 12px 24px 18px;
  box-shadow: 0 -6px 24px rgba(0,0,0,.10);
  z-index: 50;
  /* 2-row compact grid: [progress / controls + download] */
  display: grid;
  grid-template-areas: "prog prog" "ctrl dl";
  grid-template-columns: 1fr auto;
  column-gap: 28px;
  row-gap: 8px;
}
body.panel-mode .progress-wrap   { grid-area: prog; margin-bottom: 0; }
body.panel-mode .player-controls { grid-area: ctrl; margin-bottom: 0; }
body.panel-mode .download-row    { grid-area: dl;   margin-top: 0; align-items: center; flex-direction: column; gap: 6px; }
body.panel-mode .info-row        { display: none; }

@media (min-width: 768px) {
  body.panel-mode .container { padding: 20px 36px 24px; }
  body.panel-mode .player    { margin: 0 -36px; padding: 12px 36px 18px; }
  body.panel-mode .download-row { flex-direction: row; gap: 10px; }
}
@media (min-width: 1024px) {
  body.panel-mode .container { padding: 24px 44px 24px; max-width: none; }
  body.panel-mode .player    { margin: 0 -44px; padding: 12px 44px 18px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PUBLISH / COMMUNITY
   ═══════════════════════════════════════════════════════════════════════════ */

/* Sección publicar en lesson.php */
.publish-section {
  margin-top: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
#pub-idle {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}
.pub-live {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}
.pub-adopters {
  font-size: 12px;
  color: var(--muted);
}
.pub-link {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.pub-link:hover { color: var(--primary); }
.pub-link-danger { color: #dc2626; }
.pub-link-danger:hover { color: #b91c1c; }
.pub-link-share {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.pub-link-share:hover { color: #15803d; }
.publish-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.publish-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #16a34a;
  background: #dcfce7;
  border-radius: 20px;
  padding: 3px 10px;
}

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 34px; height: 19px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: #ddd; border-radius: 19px;
  transition: background .2s; cursor: pointer;
}
.toggle-switch input:checked + .toggle-track { background: #16a34a; }
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-track .toggle-thumb { transform: translateX(15px); }

/* Author badge en tarjetas de comunidad */
.author-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  background: #f3f4f6;
  border-radius: 20px;
  padding: 2px 8px;
}
.author-badge-inline {
  font-size: 11px;
  color: #6b7280;
  font-weight: 500;
}
.adopted-count {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 500;
}
.story-card-summary {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.community-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 40px 0;
}

.comm-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.comm-search-row .story-search {
  flex: 1;
  margin-bottom: 0;
}
.comm-mine-pill {
  white-space: nowrap;
  flex-shrink: 0;
}
.comm-mine-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── Learning Path ─────────────────────────────────────────────────────────── */
.path-intro { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 10px; }
.path-intro strong { color: var(--text); }

.path-level { margin-bottom: 32px; scroll-margin-top: 14px; }
.path-level-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 0 12px;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 14px;
}
.path-level-badge {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff; letter-spacing: .03em;
}
.path-level-info { flex: 1; min-width: 0; }
.path-level-name { font-size: 15px; font-weight: 700; color: var(--text); }
.path-level-range { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.path-level-desc { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.path-level-progress { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; padding-top: 2px; }

.path-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }

/* ── Changelog modal ──────────────────────────────────────────────────────── */
.nav-user-menu-btn {
  width: 100%; background: none; border: none; cursor: pointer; text-align: left;
}
.nav-user-menu-btn:hover { background: #f5f5f7; color: var(--text); }
.nav-user-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

.cl-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 1100; backdrop-filter: blur(2px);
}
.cl-overlay.open { display: block; }

.cl-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 100%; max-width: 460px;
  background: var(--bg); z-index: 1101; display: flex; flex-direction: column;
  box-shadow: -4px 0 32px rgba(0,0,0,.15);
  /* Cerrado se aparta EXACTAMENTE su propio ancho, sea el que sea.
     Antes se apartaba `right: -480px`, un numero fijo que daba por hecho que
     el panel nunca pasaria de 480px de ancho. Pero por debajo de 600px el
     `@media` lo deja al 100%, asi que entre 481px y 600px de ventana el panel
     era mas ancho que su propio desplazamiento y asomaba la diferencia por la
     derecha: 80px a 560, 120px a 600.
     Y no se veia midiendo el desbordamiento de la pagina, porque un elemento
     `fixed` no genera desplazamiento: se ve sin ensanchar nada. */
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.cl-panel.open { transform: translateX(0); }

.cl-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 24px 24px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.cl-title { font-size: 17px; font-weight: 700; color: var(--text); }
.cl-subtitle { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* Fecha de la última publicación, en la cabecera del panel de Novedades. */
.cl-updated {
  font-size: 11.5px; color: var(--muted); margin-top: 7px;
  display: inline-flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
}
.cl-updated::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}

/* Tema de cada versión: dice de qué trata el bloque antes de leer la lista. */
.cl-ver-theme {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  margin: 6px 0 10px; letter-spacing: -.01em;
}
.cl-close {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  padding: 4px; border-radius: 6px; display: flex; align-items: center;
  transition: background .12s; flex-shrink: 0;
}
.cl-close:hover { background: #f0f0f0; color: var(--text); }

.cl-body { flex: 1; overflow-y: auto; padding: 20px 24px 32px; display: flex; flex-direction: column; gap: 28px; }

.cl-version-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.cl-ver-badge {
  font-size: 12px; font-weight: 700; background: var(--text); color: #fff;
  padding: 2px 8px; border-radius: 20px; letter-spacing: .03em;
}
.cl-ver-date { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.cl-ver-tag {
  font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 20px; letter-spacing: .03em;
}
.cl-ver-tag.new { background: #dcfce7; color: #166534; }

.cl-list {
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px;
}
.cl-list li {
  display: block;
  font-size: 13px; color: var(--text); line-height: 1.45;
}
.cl-tag {
  display: inline-block; vertical-align: 1px; margin-right: 7px;
  font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 20px;
  letter-spacing: .03em; white-space: nowrap; flex-shrink: 0;
}
.cl-tag.new  { background: #16a34a; color: #fff; }
.cl-tag.fix  { background: #6b7280; color: #fff; }
.cl-tag.feat { background: #6b7280; color: #fff; }

@media (max-width: 600px) {
  .cl-panel { max-width: 100%; }
}

/* ── La noticia de las veinte plazas ──────────────────────────────────────── */
/* Sale una sola vez, arriba de la portada. Es una buena noticia, así que se
   permite el verde de acento; el resto de la página no compite con ella. */
.p20 {
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 24px 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.p20-tag {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: var(--accent);
  padding: 4px 10px; border-radius: 20px; margin-bottom: 12px;
}
.p20-t {
  font-size: 19px; font-weight: 700; color: var(--text);
  line-height: 1.3; margin-bottom: 12px;
}
.p20-p {
  font-size: 14px; line-height: 1.65; color: var(--muted); margin-bottom: 10px;
}
.p20-p b { color: var(--text); font-weight: 600; }
.p20-acciones { display: flex; gap: 14px; align-items: center; margin-top: 18px; }
.p20-btn {
  height: 40px; padding: 0 20px; border: none; border-radius: 11px;
  background: var(--accent); color: #fff;
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.p20-btn:hover { background: var(--accent-lt); }
.p20-link { font-size: 14px; color: var(--muted); }
.p20-link:hover { color: var(--text); text-decoration: underline; }

/* El distintivo permanente de Mi plan */
.pl-badges { display: flex; flex-direction: column; gap: 7px; align-items: flex-end; }
.pl-p20-badge {
  font-size: 11.5px; font-weight: 600; line-height: 1.4;
  padding: 4px 10px; border-radius: 20px; text-align: right;
  background: rgba(22,163,74,.10); color: var(--accent);
  border: 1px solid rgba(22,163,74,.25);
}
html.dark .pl-p20-badge {
  background: rgba(63,185,80,.12); border-color: rgba(63,185,80,.30);
}

@media (max-width: 600px) {
  .p20 { padding: 20px; }
  .p20-t { font-size: 17px; }
  .pl-badges { align-items: flex-start; }
  .pl-p20-badge { text-align: left; }
}


/* ── El método: la idea central y la curva del olvido ─────────────────── */
.idea-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px 24px; margin-bottom: 14px;
}
.idea-t { font-size: 17px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 8px; }
.idea-p { font-size: 14px; line-height: 1.65; color: var(--muted); margin-bottom: 18px; }
.idea-tres { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.idea-tres b {
  display: block; font-size: 13.5px; font-weight: 700; color: var(--text); margin-bottom: 4px;
}
.idea-tres span { font-size: 13px; line-height: 1.55; color: var(--muted); }

.curva-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px 24px 18px; margin-bottom: 18px;
}
.curva-card .curva-t { font-size: 15px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 4px; }
.curva-card .curva-s { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 18px; }
.curva-card .curva-fila {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: baseline;
}
.curva-card .curva-fila + .curva-fila { margin-top: 18px; }
.curva-card .curva-cuando { font-size: 14.5px; font-weight: 700; color: var(--text); }
.curva-card .curva-cuantas { font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.curva-card .curva-cuantas b { font-size: 16.5px; font-weight: 800; color: var(--text); }
/* Los puntos son el dato: diez palabras, y se cuentan con el dedo. */
.curva-card .curva-puntos { grid-column: 1 / -1; display: flex; gap: 6px; margin-top: 4px; }
.curva-card .curva-puntos i {
  width: 100%; max-width: 26px; height: 10px; border-radius: 99px;
  background: var(--bg-alt); border: 1px solid var(--border);
}
.curva-card .curva-puntos i.on { background: var(--accent); border-color: var(--accent); }
.curva-card .curva-fila.alta .curva-cuantas b { color: var(--accent); }
.curva-card .curva-fila.baja .curva-puntos i.on {
  background: var(--muted); border-color: var(--muted); opacity: .6;
}
.curva-card .curva-pie {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--muted); line-height: 1.6;
}
.curva-card .curva-pie b { color: var(--text); font-weight: 600; }
.curva-card .curva-remate {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  background: rgba(22,163,74,.08); border: 1px solid rgba(22,163,74,.22);
  font-size: 13px; color: var(--text); line-height: 1.55;
}
html.dark .curva-card .curva-remate { background: rgba(63,185,80,.10); border-color: rgba(63,185,80,.24); }
.curva-card .curva-remate b { font-weight: 700; }
.curva-card .curva-fuente { margin-top: 12px; font-size: 11.5px; color: var(--muted); opacity: .8; line-height: 1.5; }

@media (max-width: 700px) {
  .idea-tres { grid-template-columns: 1fr; gap: 12px; }
  .idea-card, .curva-card { padding: 18px; }
}
