/* Unidad de contenido: portada con lecciones, conceptos y práctica.
 * Tokens, armazón, iconos (.ic, .ic-caja) y botones vienen de app.css. */

.unidad { max-width: 960px; }

/* ---------- Banner de la unidad ----------
 * En línea con el del inicio (css/home.css). El dibujo y las fórmulas del tema los pone
 * js/banner-unidad.js dentro de .u-arte; --c es el color de acento del área. */
.u-head {
  --c: #7DD3FC;
  position: relative; isolation: isolate; overflow: hidden; margin: 0 0 4px;
  min-height: 372px; display: flex; flex-direction: column; justify-content: center;
  padding: clamp(22px, 3.2vw, 36px); border-radius: 20px; color: #fff;
  background:
    radial-gradient(55% 90% at 84% 50%, rgba(59, 130, 246, .40) 0%, rgba(59, 130, 246, 0) 70%),
    radial-gradient(45% 70% at 6% 0%, rgba(99, 102, 241, .34) 0%, rgba(99, 102, 241, 0) 70%),
    linear-gradient(135deg, #0B1B36 0%, #12284A 50%, #0E2145 100%);
  box-shadow: 0 20px 48px -26px rgba(11, 27, 54, .65);
}
.u-head > :not(.u-arte) { position: relative; z-index: 1; max-width: min(100%, 24rem); }
.u-head .migas { margin: 0 0 14px; color: #C5D4EE; }
.u-head .migas a { color: #BFD3FB; }
.u-head .migas > .ic { color: rgba(255, 255, 255, .45); }
.u-head .migas [aria-current] { color: #fff; }
.u-head h1 { margin: 0 0 12px; color: #fff; font-size: clamp(30px, 4vw, 44px); font-weight: 750; line-height: 1.06; letter-spacing: -.025em; }
.u-kicker {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-size: 13px; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; color: var(--c);
}
.u-kicker::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 25%, transparent); }
.u-lead { margin: 0; font-size: 16.5px; line-height: 1.55; color: #D3DEF1; }
.u-head :focus-visible { outline-color: #fff; }

.u-arte { position: absolute; inset: 0; z-index: 0; }
/* Papel cuadriculado muy tenue, solo como ambiente del lado del texto */
.u-arte::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: linear-gradient(90deg, #000 0%, transparent 55%); mask-image: linear-gradient(90deg, #000 0%, transparent 55%);
}
/* La figura: lienzo de 560 × 360; las notas se colocan en % de este recuadro */
.u-fig { position: absolute; right: 2.2%; top: calc(50% - 15px); transform: translateY(-50%); width: 48%; aspect-ratio: 560 / 360; }
.u-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.u-svg .malla { stroke: rgba(255, 255, 255, .07); stroke-width: 1; }
.u-svg .eje { stroke: rgba(255, 255, 255, .5); stroke-width: 1.2; }
.u-svg .num { fill: rgba(255, 255, 255, .5); stroke: none; font: 500 10.5px var(--font); text-anchor: middle; font-variant-numeric: tabular-nums; }
.u-svg .num.it { font: italic 13px "KaTeX_Math", "Times New Roman", serif; fill: rgba(255, 255, 255, .7); }
.u-svg .punteada { stroke: rgba(255, 255, 255, .34); stroke-width: 1.1; stroke-dasharray: 3 6; }
.u-svg .curva {
  stroke: var(--k); stroke-width: 2.1; stroke-dasharray: 1; stroke-dashoffset: 1;
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--k) 55%, transparent));
  animation: u-trazo 1.5s var(--d, 0s) cubic-bezier(.5, 0, .2, 1) forwards;
}
.u-svg .curva.gruesa { stroke-width: 3; }
.u-svg .curva.raya { stroke-dasharray: .018 .014; stroke-dashoffset: 0; opacity: 0; animation: u-ver .8s var(--d, 0s) ease-out forwards; }
.u-svg .pto { fill: #0E2145; stroke: var(--k); stroke-width: 2.2; }
.u-svg .halo { fill: var(--k); opacity: .16; stroke: none; }
.u-svg .guia { stroke: var(--k); stroke-width: 1; opacity: 0; animation: u-ver .6s var(--d, 0s) ease-out forwards; --op: .7; }
.u-svg .guia-p { fill: var(--k); stroke: none; opacity: 0; animation: u-ver .6s var(--d, 0s) ease-out forwards; }
/* Dibujos (unidades sin plano) */
.u-svg .dibujo .t { stroke: var(--c); stroke-width: 2.4; }
.u-svg .dibujo .t.g { stroke-width: 8; }
.u-svg .dibujo .s { stroke: rgba(255, 255, 255, .42); stroke-width: 1.4; }
.u-svg .dibujo .r { fill: var(--c); stroke: none; }
.u-svg .dibujo .r.f { opacity: .3; }
.u-svg .dibujo .r.f2 { opacity: .55; }
.u-svg .dibujo text { fill: #fff; stroke: none; font: italic 28px "KaTeX_Main", "Times New Roman", serif; text-anchor: middle; }
.u-svg .dibujo text.p { fill: var(--c); font-size: 22px; }
.u-fig.dibujo .u-svg .dibujo { animation: u-ver .9s .1s ease-out both; }
.u-svg .dibujo .t.fino { stroke-width: 1.3; opacity: .8; }
.u-svg .dibujo .d { stroke-dasharray: 4 6; }
.u-svg .dibujo text.v { fill: #fff; font: 600 20px var(--font); font-variant-numeric: tabular-nums; }
/* Tirador: el punto que se mueve */
@keyframes u-pulso { 0%, 100% { transform: scale(.7); opacity: .34; } 50% { transform: scale(1.35); opacity: .08; } }

/* Nota: rótulo en el color de su curva + fórmula */
.nota {
  position: absolute; display: grid; gap: 3px; white-space: nowrap; transform: translateY(-50%); pointer-events: none;
  opacity: 0; animation: u-ver .6s var(--d, 0s) ease-out forwards;
}
.nota.al-r { transform: translate(-100%, -50%); justify-items: end; }
.nota.al-c { transform: translate(-50%, -50%); justify-items: center; }
.nota .rot { display: flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--k); }
.nota .rot::before { content: ""; width: 14px; height: 2px; border-radius: 1px; background: var(--k); }
.nota.al-r .rot { flex-direction: row-reverse; }
.nota .tex { font-size: 15px; color: #fff; }
.nota .tex .katex { font-size: 1em; }
.u-fig.dibujo .nota .tex { font-size: 14.5px; }

/* Sonda */
.sonda { opacity: 0; transition: opacity .15s; }
.sondeando .sonda { opacity: 1; }
.sonda-l { stroke: rgba(255, 255, 255, .55); stroke-width: 1; stroke-dasharray: 2 4; }
.sonda-p { fill: var(--k); stroke: #0B1B36; stroke-width: 2; }
.lectura {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%); display: flex; gap: 14px; align-items: center; white-space: nowrap;
  padding: 6px 12px; border-radius: 99px; background: rgba(6, 16, 36, .78); border: 1px solid rgba(255, 255, 255, .16);
  font-size: 12.5px; font-variant-numeric: tabular-nums; color: #DCE7FA; opacity: 0; transition: opacity .15s; pointer-events: none;
}
.sondeando .lectura { opacity: 1; }
/* Lectura de las figuras con parámetro: siempre visible, bajo el dibujo */
.lectura.fija {
  left: 1%; top: 74%; transform: none; opacity: 1; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 8px 14px 9px; border-radius: 13px; font-size: 13px;
}
.lectura.fija b { font-size: 13.5px; letter-spacing: -.005em; }
.lectura.fija span { color: var(--c); font-weight: 600; }
.lectura.fija span::before { content: none; }
.lectura b { color: #fff; font-weight: 650; }
.lectura span { display: inline-flex; align-items: center; gap: 6px; }
.lectura span::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--k); }
.sondeando .nota { opacity: .35 !important; transition: opacity .15s; }

@keyframes u-trazo { to { stroke-dashoffset: 0; } }
@keyframes u-ver { from { opacity: 0; } to { opacity: var(--op, 1); } }
@media (max-width: 860px) {
  /* En columna: la figura va arriba, completa; el texto, debajo, a todo el ancho */
  .u-head { min-height: 0; padding-top: calc(min(100vw - 28px, 520px) * .6 + 26px); }
  .u-head > :not(.u-arte) { max-width: none; }
  .u-fig { right: auto; left: 50%; top: 16px; transform: translateX(-50%); width: min(100% - 36px, 480px); }
  .nota .rot { font-size: 9px; letter-spacing: .08em; }
  .nota .tex, .u-fig.dibujo .nota .tex { font-size: 11.5px; }
  .u-fig.dibujo .nota .rot { font-size: 8px; letter-spacing: .05em; gap: 4px; }
  .u-fig.dibujo .nota .rot::before { width: 8px; }
  .u-fig.dibujo .nota .tex { font-size: 11px; }
  .u-svg .dibujo text { font-size: 27px; }
  .lectura.fija { top: 74%; padding: 6px 10px 7px; font-size: 10.5px; border-radius: 10px; }
  .lectura.fija b { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .u-svg .curva { animation: none; stroke-dashoffset: 0; }
  .u-svg .curva.raya, .u-svg .guia-p, .nota, .u-fig.dibujo .u-svg .dibujo { animation: none; opacity: 1; }
  .u-svg .guia { animation: none; opacity: .7; }
  .u-toc a, .u-toc a::after, .u-toc a::before, .u-toc .ic-caja { transition: none; }
}
@media print {
  .u-head { background: none; box-shadow: none; color: inherit; padding: 0; min-height: 0; }
  .u-head h1, .u-lead, .u-head .migas [aria-current] { color: #000; }
  .u-arte { display: none; }
}

/* Avance de la unidad (lo pinta js/unidad.js cuando hay lecciones completadas) */
.u-avance { margin-top: 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.u-barra { flex: none; width: min(260px, 100%); height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.u-barra i { display: block; height: 100%; width: 0; border-radius: 4px; background: #5EEAD4; transition: width .4s ease; }
.u-avance p { margin: 0; font-size: 14.5px; font-weight: 600; color: #99F6E4; }

/* Navegación entre secciones: un riel con el recorrido de la unidad (1 Conceptos → 2 Lecciones → 3 Práctica).
 * Una sola pieza que monta sobre el borde inferior del banner. Cada paso tiene su color (--k); la línea superior
 * de «Lecciones» muestra el avance real (--p, lo pone js/banner-unidad.js). */
.u-toc { position: relative; z-index: 2; margin: -44px clamp(10px, 2.4vw, 26px) 0; }
.u-head { padding-bottom: calc(clamp(22px, 3.2vw, 36px) + 44px); }
.u-toc ol {
  margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); counter-reset: paso;
  background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .7); border-radius: 22px; overflow: hidden;
  box-shadow: 0 26px 46px -24px rgba(11, 27, 54, .55), 0 2px 6px rgba(23, 43, 77, .06);
}
.u-toc li { position: relative; counter-increment: paso; --k: #2563EB; --k2: #6366F1; --p: 0; }
.u-toc li:nth-child(2) { --k: #0D9488; --k2: #0EA5E9; }
.u-toc li:nth-child(3) { --k: #D97706; --k2: #F43F5E; }
.u-toc li + li { border-left: 1px solid var(--border); }
.u-toc a {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 13px; height: 100%; min-height: 92px;
  padding: 18px 14px 16px 18px; color: var(--primary-dark); text-decoration: none; transition: background .2s;
}
/* Línea superior: pista + avance */
.u-toc li::before { content: ""; position: absolute; z-index: 1; left: 0; right: 0; top: 0; height: 4px; background: color-mix(in srgb, var(--k) 14%, #fff); }
.u-toc a::after {
  content: ""; position: absolute; z-index: 2; left: 0; right: 0; top: 0; height: 4px; background: linear-gradient(90deg, var(--k), var(--k2));
  transform: scaleX(var(--p)); transform-origin: left; transition: transform .45s cubic-bezier(.2, .7, .2, 1);
}
.u-toc a:hover, .u-toc a:focus-visible { background: color-mix(in srgb, var(--k) 6%, #fff); }
.u-toc a:hover::after, .u-toc a:focus-visible::after { transform: scaleX(1); }
.u-toc a:focus-visible { outline-offset: -3px; }
.u-toc .ic-caja {
  position: relative; width: 50px; height: 50px; border-radius: 50%; color: #fff; background: linear-gradient(140deg, var(--k), var(--k2));
  box-shadow: 0 10px 20px -10px var(--k), inset 0 1px 0 rgba(255, 255, 255, .35); transition: transform .25s cubic-bezier(.2, .7, .2, 1);
}
.u-toc .ic-caja .ic { width: 24px; height: 24px; }
/* Número del paso, sobre el icono */
.u-toc .ic-caja::after {
  content: counter(paso); position: absolute; right: -5px; top: -5px; width: 21px; height: 21px; border-radius: 50%; display: grid; place-items: center;
  background: #fff; color: var(--k); font-size: 12px; font-weight: 750; line-height: 1; box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--k) 35%, #fff), 0 2px 5px rgba(23, 43, 77, .18);
}
.u-toc a:hover .ic-caja, .u-toc a:focus-visible .ic-caja { transform: scale(1.07); }
.toc-t { min-width: 0; display: grid; gap: 1px; }
.toc-t::before { content: "Paso " counter(paso); font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--k); }
.toc-t b { font-size: 17.5px; font-weight: 720; line-height: 1.2; letter-spacing: -.012em; }
.toc-t small { font-size: 13px; color: var(--text-secondary-strong); line-height: 1.3; }
.u-toc li.con-avance small { color: var(--k); font-weight: 600; }
/* Flecha que aparece al pasar */
.u-toc a::before {
  content: ""; position: absolute; right: 12px; top: 14px; width: 26px; height: 26px; border-radius: 50%;
  background: color-mix(in srgb, var(--k) 10%, #fff) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23183153' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 6v12M6.5 12.5L12 18l5.5-5.5'/%3E%3C/svg%3E") center / 16px no-repeat;
  opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s;
}
.u-toc a:hover::before, .u-toc a:focus-visible::before { opacity: 1; transform: none; }

/* Secciones */
.u-sec { margin-top: clamp(32px, 4.5vw, 52px); }
.sec-head { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.sec-head h2 { margin: 0; font-size: 23px; font-weight: 680; letter-spacing: -.01em; line-height: 1.2; scroll-margin-top: calc(var(--header-h) + 20px); }
.sec-n { margin-left: auto; flex: none; font-size: 13.5px; font-weight: 550; color: var(--text-secondary-strong); white-space: nowrap; }
.sec-lead { max-width: 46em; color: var(--text-secondary-strong); }

.u-sec h3 { margin: 28px 0 8px; font-size: 18.5px; font-weight: 650; }
.u-sec p { margin: 0 0 12px; }
.u-sec ul, .u-sec ol { margin: 0 0 14px; padding-left: 1.5em; }
.u-sec li { margin: 4px 0; }
.u-sec li > p { margin: 0; }
.u-sec li > ul, .u-sec li > ol { margin: 4px 0 0; }

.formula {
  margin: 10px 0 12px !important; padding: 12px 16px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 8px;
  font-size: 19px; font-weight: 550; color: var(--primary-dark); letter-spacing: .01em;
}
.formula + .formula { margin-top: -4px !important; }
/* Desarrollo paso a paso (REGLA «PASO A PASO»), con la rejilla de la pizarra: cada expresión empieza
 * en el borde; la fila que continúa pone su «=» debajo del de esa expresión (lleva delante, invisible,
 * su lado izquierdo); las anotaciones van en una misma columna, con su raya de comentario
 * (debajo de la fila, en el teléfono). */
.des {
  display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 20px; row-gap: 8px; align-items: center;
  margin: 10px 0 14px; padding: 12px 16px; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: 8px;
  font-size: 17.5px; font-weight: 550; color: var(--primary-dark);
}
.concepto .des { background: var(--claudia-light); }
.des-f { white-space: nowrap; }
.des-o { visibility: hidden; }
.des-p { padding: 1px 0 1px 10px; border-left: 2px solid var(--border-strong); font-size: 14px; font-weight: 450; line-height: 1.35; color: var(--text-secondary-strong); }
.des-p:empty { visibility: hidden; }
@media (max-width: 680px) {
  .des { grid-template-columns: minmax(0, 1fr); row-gap: 5px; padding: 10px 12px; font-size: 16px; }
  .des-p { margin-bottom: 5px; }
  .des-p:empty { display: none; }
}

.fig { margin: 12px 0 14px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.fig svg { display: block; width: 100%; height: auto; }
/* Figura interactiva (js/figuras.js): trae su propio marco. */
.fig.fig-i, .concepto .fig.fig-i { padding: 0; border: 0; background: none; }
.fig-i .figi { background: var(--surface); }
.fig-i .figi .ic { display: inline-block; width: 17px; height: 17px; min-width: 0; }
.fig-i .figi .figi-pie, .fig-i .figi .figi-pista, .fig-i .figi .figi-t, .fig-i .figi .figi-f { margin-left: 0; margin-right: 0; }
.fig-i .fig-fija { padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.fig figcaption { margin-top: 6px; text-align: center; color: var(--text-secondary); font-size: 13.5px; }

.tabla { margin: 8px 0 18px; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tabla table { width: 100%; border-collapse: collapse; font-size: 15px; }
.tabla th, .tabla td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.tabla th { background: var(--claudia-light); color: var(--primary-dark); font-size: 13.5px; font-weight: 650; white-space: nowrap; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla td p, .tabla th p { margin: 0; }
.tabla td:first-child { font-variant-numeric: tabular-nums; }

/* ---------- Lecciones ---------- */
.lecs { list-style: none; margin: 0 !important; padding: 0 !important; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.lec {
  margin: 0 !important; padding: 18px 20px 20px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.lec:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.lec-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; }
.lec-n { display: inline-flex; align-items: center; gap: 10px; }
.lec-num { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); font-size: 14.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.lec-lbl { font-size: 12.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--text-secondary); }
.lec-estado { display: inline-flex; align-items: center; gap: 5px; font-size: 13.5px; font-weight: 650; color: var(--success); }
.lec-estado .ic { width: 18px; height: 18px; }
.lec.hecha .lec-num { background: var(--success-soft); color: var(--success); }
.lec h3 { margin: 12px 0 4px; font-size: 19.5px; font-weight: 680; line-height: 1.25; letter-spacing: -.005em; }
.lec .lec-desc { margin: 0 0 12px; font-size: 15.5px; line-height: 1.5; color: var(--text-secondary-strong); }
.lec-meta { list-style: none; margin: 0 0 16px !important; padding: 0 !important; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--text-secondary); }
.lec-meta li { margin: 0; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.lec-meta .ic { width: 17px; height: 17px; }
.lec-pie { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 12px; }
.lec-pie .btn { min-width: 132px; }
.lec-tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 8px; border-radius: 99px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  color: var(--text-secondary-strong); background: var(--background); border: 1px solid var(--border);
}
.lec-tag .ic { width: 15px; height: 15px; }
.lec-tag.t-video { color: var(--success); background: var(--success-soft); border-color: transparent; }

/* ---------- Conceptos plegables ---------- */
.concepto { margin: 0 0 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: border-color .15s; }
.concepto:hover, .concepto[open] { border-color: var(--border-strong); }
.concepto > summary {
  display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 12px 16px 12px 12px;
  font-size: 17px; font-weight: 650; line-height: 1.3; color: var(--primary-dark); cursor: pointer; list-style: none;
  border-radius: var(--radius-sm);
}
.concepto > summary::-webkit-details-marker, .ej summary::-webkit-details-marker { display: none; }
.concepto > summary .ic, .ej summary .ic { color: var(--primary); transition: transform .18s ease; }
.concepto > summary .ic { width: 20px; height: 20px; }
.concepto[open] > summary .ic, .ej details[open] summary .ic { transform: rotate(90deg); }
.concepto > summary:active { background: var(--primary-soft); }
.concepto[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.concepto-c { padding: 16px 18px 6px; }
.concepto .formula { background: var(--claudia-light); }
.concepto .fig { border-color: var(--border); background: var(--claudia-light); }
.nv { display: inline-block; margin-left: 6px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 650; letter-spacing: .01em; vertical-align: 2px; white-space: nowrap; }
.nv-e { background: var(--primary-soft); color: var(--primary-dark); }
.nv-a { background: var(--warning-soft); color: var(--warning-strong); }

/* ---------- Práctica ---------- */
.u-sec h3.ej-nivel { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin: 28px 0 12px; }
.ej-nivel small { margin-left: auto; font-size: 13.5px; font-weight: 500; color: var(--text-secondary); }
.ejs { list-style: none; margin: 0 0 8px !important; padding: 0 !important; display: grid; gap: 10px; }
.ej { margin: 0 !important; display: flex; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.ej-n { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.ej-c { min-width: 0; flex: 1; }
.ej-q { margin: 2px 0 10px !important; font-size: 17px; font-weight: 500; }
.ej summary {
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 6px 16px 6px 10px;
  border: 1.5px solid var(--border-strong); border-radius: 99px;
  font-size: 14.5px; font-weight: 600; color: var(--primary-dark); cursor: pointer; list-style: none;
  transition: background .15s, border-color .15s;
}
.ej summary .ic { width: 16px; height: 16px; }
.ej summary:hover, .ej details[open] summary { background: var(--primary-soft); border-color: var(--primary); }
.ej details[open] summary { margin-bottom: 10px; }
.ej-r { margin: 0 0 4px !important; padding: 8px 12px; border-left: 3px solid var(--success); background: var(--success-soft); border-radius: 6px; font-weight: 650; color: var(--success); }
.ej-s { margin: 6px 0 0 !important; color: var(--text-secondary-strong); font-size: 15.5px; }
.u-pdf { margin: 36px 0 8px; }

/* ---------- Práctica con pestañas, comprobación en dos pasos y avance (js/practica.js) ---------- */
.u-avance-p { flex-basis: 100%; color: #C5D4EE !important; font-weight: 550 !important; }
.prac-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 4px 0 18px; }
.prac-tab {
  display: grid; gap: 1px; padding: 10px 14px; text-align: left;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); transition: border-color .15s, background .15s;
}
.prac-tab:hover { border-color: var(--primary); }
.prac-tab[aria-selected="true"] { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 -3px 0 var(--primary); }
.prac-tab-t { font-size: 16px; font-weight: 680; color: var(--primary-dark); }
.prac-tab-s { font-size: 13.5px; color: var(--text-secondary-strong); line-height: 1.3; }
.prac-tab-n { margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--text-secondary-strong); font-variant-numeric: tabular-nums; }
.prac-tab.completo .prac-tab-n { color: var(--success); }
.u-sec h3.prac-h { margin: 0 0 12px; font-size: 18px; }

/* Lista de ejercicios: una sola columna dentro de un mismo recuadro, con filas uniformes separadas
 * por una línea fina (como una hoja de ejercicios). Sin huecos ni tarjetas de anchos distintos. */
.pes { list-style: none; margin: 0 !important; padding: 0 !important; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.pe { position: relative; margin: 0 !important; border-top: 1px solid var(--border); transition: background .15s; }
.pe:first-child { border-top: 0; }
.pe:not(.abierto):hover { background: var(--claudia-light); }
.pe.abierto { background: var(--claudia-light); }
/* Estado: una barra a la izquierda (además del número y la etiqueta). */
.pe.ok::before, .pe.mal::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.pe.ok::before { background: var(--success); }
.pe.mal::before { background: var(--danger); }
.pe-fila { display: flex; align-items: center; gap: 14px; min-height: 62px; padding: 9px 12px 9px 16px; }
.pe-n { flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.pe.ok .pe-n { background: var(--success); color: #fff; }
.pe.mal .pe-n { background: var(--danger-soft); color: var(--danger); }
.pe-q { flex: 1; min-width: 0; margin: 0 !important; display: grid; gap: 1px; }
.pe-verbo { font-size: 12.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--text-secondary); }
.pe-expr { font-size: 19px; line-height: 1.35; color: var(--text-primary); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.pe-expr::-webkit-scrollbar { display: none; }
.pe-expr .katex, .pe-m .katex { font-size: 1.04em; }
.pe-expr.pe-texto { font-size: 16.5px; line-height: 1.4; overflow: visible; }
.pe-y { margin: 0 .5em; font-size: 15px; color: var(--text-secondary); }
.pe-estado { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 650; white-space: nowrap; }
.pe-estado .ic { width: 16px; height: 16px; }
.pe.ok .pe-estado { color: var(--success); }
.pe.mal .pe-estado { color: var(--danger); }
/* Botón AIDA de cada ejercicio: abre la ventana de razonamiento (js/aida.js). */
.pe-aida {
  flex: none; min-height: 40px; padding: 6px 13px; border-radius: 99px; background: var(--surface);
  border: 1.5px solid var(--border-strong); color: var(--primary-dark); font: inherit; font-size: 14.5px; font-weight: 600; white-space: nowrap;
}
.pe-aida:hover { background: var(--primary-soft); }
.pe-abrir {
  flex: none; display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 6px 8px 6px 12px;
  background: transparent; border: 0; border-radius: 99px; font-size: 14.5px; font-weight: 600; color: var(--primary);
}
.pe-abrir:hover, .pe-abrir:active { background: var(--primary-soft); }
.pe-abrir .ic { width: 18px; height: 18px; transition: transform .18s ease; }
.pe-abrir[aria-expanded="true"] .ic { transform: rotate(90deg); }

.pe-det { padding: 4px 16px 16px 60px; display: grid; gap: 10px; justify-items: start; max-width: 760px; }
.pe-r { margin: 0 !important; width: 100%; padding: 8px 12px; border-left: 3px solid var(--success); background: var(--success-soft); border-radius: 6px; display: grid; gap: 1px; }
.pe-k { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--success); }
.pe-r .pe-m { font-size: 18px; font-weight: 600; color: var(--text-primary); overflow-x: auto; overflow-y: hidden; }
.pe-ver {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px 6px 10px;
  background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: 99px;
  font-size: 14.5px; font-weight: 600; color: var(--primary-dark);
}
.pe-ver:hover, .pe-ver[aria-expanded="true"] { background: var(--primary-soft); border-color: var(--primary); }
.pe-ver .ic { width: 17px; height: 17px; }
/* Procedimiento línea por línea; las líneas que continúan una igualdad («= …») van sangradas. */
.pe-s { list-style: none; width: 100%; margin: 0 !important; padding: 2px 0 2px 14px !important; border-left: 2px solid var(--border); display: grid; gap: 7px; }
.pe-s li { margin: 0; font-size: 16px; line-height: 1.5; color: var(--text-primary); overflow-x: auto; overflow-y: hidden; }
.pe-s li.cont { padding-left: 1.7em; }
.pe-s .katex, .pe-texto .katex { font-size: 1.06em; }
/* Enunciado en frases: una línea por cláusula; ocupa las dos columnas. */
.pe-linea { display: block; }
.pe-linea + .pe-linea { margin-top: 3px; }
.pe-expr.pe-texto { max-width: 46em; }
.pe-auto { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; padding-top: 10px; border-top: 1px dashed var(--border); }
.pe-auto-t { margin-right: 4px; font-size: 14.5px; font-weight: 600; color: var(--text-primary); }
.pe-marca {
  display: inline-flex; align-items: center; gap: 5px; min-height: 44px; padding: 6px 16px 6px 12px;
  background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; color: var(--text-primary); transition: background .15s, border-color .15s, color .15s;
}
.pe-marca .ic { width: 17px; height: 17px; stroke-width: 2.2; }
.pe-ok:hover { border-color: var(--success); background: var(--success-soft); }
.pe-mal:hover { border-color: var(--danger); background: var(--danger-soft); }
.pe-ok[aria-pressed="true"] { background: var(--success); border-color: var(--success); color: #fff; }
.pe-mal[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.pe-repaso { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: 14.5px; font-weight: 600; text-decoration: none; }
.pe-repaso:hover { text-decoration: underline; }
.pe-repaso .ic { width: 16px; height: 16px; }

@media (max-width: 680px) {
  .prac-tabs { gap: 6px; }
  .prac-tab { padding: 8px 8px; text-align: center; justify-items: center; }
  .prac-tab-s { display: none; }
  .prac-tab-t { font-size: 15px; }
  .prac-tab-n { font-size: 12px; margin-top: 0; }
  .pe-fila { gap: 10px; padding: 9px 6px 9px 12px; }
  .pe-det { padding: 2px 12px 14px; }
  .pe-abrir span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .pe-abrir { width: 44px; padding: 0; justify-content: center; }
  /* En el teléfono «¡Oriéntame!» va debajo del enunciado, para no estrecharlo. */
  .pe-fila { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; column-gap: 10px; row-gap: 6px; }
  .pe-n { grid-column: 1; grid-row: 1; } .pe-q { grid-column: 2; grid-row: 1; } .pe-estado { grid-column: 3; grid-row: 1; } .pe-abrir { grid-column: 4; grid-row: 1; }
  .pe-aida { grid-column: 2 / 5; grid-row: 2; justify-self: start; min-height: 40px; padding: 6px 14px; font-size: 14px; }
  .pe-estado { font-size: 0; gap: 0; }   /* en teléfono el estado se ve en el número y el icono */
  .pe-expr { font-size: 18px; }
  .pe-marca { flex: 1 1 0; justify-content: center; }
  .pe-auto-t { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) { .pe-abrir .ic { transition: none; } }
@media print {
  .prac-tabs, .pe-abrir, .pe-aida, .pe-ver, .pe-auto, .pe-repaso { display: none !important; }
  .prac .prac-panel[hidden], .prac .pe-det[hidden], .prac .pe-s[hidden] { display: block !important; }
}

@media (min-width: 1000px) {
  .tabla td:first-child { white-space: nowrap; }
}

@media (max-width: 680px) {
  .tabla table { min-width: 560px; font-size: 14.5px; }
  .lecs { grid-template-columns: 1fr; gap: 12px; }
  .fig { overflow-x: auto; }
  .fig svg { min-width: 600px; }
  .fig.fig-i { overflow-x: visible; }
  .fig-i .figi svg { min-width: 0; }
  .formula { font-size: 16.5px; padding: 10px; }
  .u-lead { font-size: 16.5px; }
  /* Accesos a secciones: icono arriba y nombre abajo, tres en una fila */
  .u-toc { margin: -40px 8px 0; }
  .u-head { padding-bottom: 62px; }
  .u-toc ol { border-radius: 18px; }
  .u-toc a { grid-template-columns: 1fr; justify-items: center; gap: 8px; min-height: 100px; padding: 18px 4px 12px; text-align: center; }
  .u-toc a::before, .toc-t::before { display: none; }
  .u-toc .ic-caja { width: 44px; height: 44px; }
  .toc-t b { font-size: 14.5px; }
  .toc-t small { display: none; }
  .sec-head h2 { font-size: 21px; }
  .sec-head .ic-caja { width: 36px; height: 36px; }
  .lec { padding: 16px; }
  .lec-pie .btn { flex: 1 1 auto; }
  .concepto > summary { font-size: 16.5px; }
  .concepto-c { padding: 14px 14px 4px; }
  .ej { gap: 10px; padding: 12px; }
  .ej-n { width: 28px; height: 28px; font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .u-barra i, .concepto > summary .ic, .ej summary .ic { transition: none; }
}

@media print {
  .top, .nav, .nav-scrim, .u-toc, .u-pdf, .u-avance { display: none !important; }
  body { display: block; background: #fff; }
  .u-sec h3, .fig, .tabla tr { break-inside: avoid; }
}

/* Conceptos: separación entre las partes de una fórmula destacada (tools/build_a1.py, tipografiar) */
.formula .f-sep { display: inline-block; width: 1.4em; }

/* Figura de Conceptos: obtención de los datos a la derecha de la gráfica (js/graficas.js, «obtencion») */
.figi-obt { display: grid; gap: 6px; }
.figi-obt-rot { margin: 6px 0 0; font-weight: 650; color: var(--primary-dark, #0B1B36); }
.figi-obt .des { margin: 0; }
