/* ==========================================================================
   Bajo Nivel — components.css
   Visualizaciones, demos y bloques específicos de cada capítulo.
   ========================================================================== */

/* ---------- Pirámide de conceptos ---------- */
.pyramid-wrap { margin: 0 0 2rem; }
.pyramid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
  max-width: 840px;
  margin: 0 auto;
}
.pyramid li {
  position: relative;
  width: max(var(--w), 250px);
  max-width: 100%;
  text-align: center;
  padding: .85rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.pyramid li:first-child { background: var(--surface-2); border-color: var(--line-strong); }
.pyramid li + li::before {
  content: "";
  position: absolute;
  top: -.58rem;
  left: 50%;
  width: 1px;
  height: .58rem;
  background: var(--line-strong);
}
.py-name { display: block; font-size: .96rem; font-weight: 600; color: var(--ink); }
.py-desc { display: block; margin-top: .15rem; font-size: .78rem; line-height: 1.45; color: var(--muted); }
.py-caption {
  max-width: 62ch;
  margin: 1.1rem auto 0;
  text-align: center;
  font-size: .78rem;
  line-height: 1.55;
  color: var(--faint);
}

/* ---------- Leyenda de lectura ---------- */
.legend-panel {
  margin-top: 2rem;
  padding: 1.3rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
}
.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-top: .9rem;
}
.legend-grid p { margin-top: .45rem; font-size: .82rem; line-height: 1.55; color: var(--muted); }

/* ---------- Flujo texto → vectores ---------- */
.flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .65rem;
  margin: 0 0 1.7rem;
}
.flow li {
  position: relative;
  padding: .8rem .9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.flow li:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -.62rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  padding: 0 .12rem;
  background: var(--bg);
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: .78rem;
}
.flow span {
  display: block;
  font-family: var(--font-mono);
  font-size: .62rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.flow small {
  display: block;
  margin-top: .25rem;
  font-family: var(--font-mono);
  font-size: .74rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* ---------- Predictor ---------- */
.pred-text {
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 4vw, 2.2rem);
  line-height: 1.25;
  color: var(--ink);
  margin: .2rem 0 1.2rem;
  min-height: 1.3em;
}
.pred-text::after {
  content: "▌";
  margin-left: .08em;
  color: var(--accent);
  animation: blink 1.15s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.pred-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: .45rem;
}
.pred-opt {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .6rem;
  padding: .7rem .8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  text-align: left;
  transition: border-color .2s, background .2s, transform .2s;
}
.pred-opt:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.pred-word { font-family: var(--font-mono); font-size: .9rem; color: var(--ink); }
.pred-track { height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.pred-fill { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-4)); }
.pred-pct { font-family: var(--font-mono); font-size: .68rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.pred-end {
  padding: 1rem;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.6;
}
.pred-end strong { color: var(--accent-text); font-weight: 500; }

/* ---------- Tokenizador ---------- */
.tok-layout {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 1.4rem;
}
.tok-input-side { min-width: 0; }
.tok-input-side .textarea {
  margin-top: .1rem;
  min-height: 122px;
  font-family: var(--font-mono);
  font-size: .82rem;
}
.tok-input-side .sample-row { margin-top: .55rem; }
.tok-output-side { display: flex; flex-direction: column; gap: .55rem; min-width: 0; }
.tok-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .7rem;
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--muted);
}
.tok-stats strong { color: var(--accent-text); font-size: 1rem; font-weight: 500; }
.tok-stats #tok-ratio { margin-right: auto; }
.token-list {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: .3rem;
  min-height: 122px;
  padding: .7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
}
.token {
  font-family: var(--font-mono);
  font-size: .76rem;
  line-height: 1.4;
  padding: .2rem .42rem;
  border: 1px solid currentColor;
  border-radius: 5px;
  background: color-mix(in srgb, currentColor 9%, transparent);
  color: var(--ink-soft);
  cursor: default;
  transition: transform .15s;
  white-space: pre;
}
.token:hover { transform: translateY(-2px); }
.token.cont { border-style: dashed; }
.token.cont::before { content: "·"; margin-right: .05em; opacity: .55; }
.token.alt-0 { color: var(--accent-text); }
.token.alt-1 { color: var(--accent-2); }
.token.alt-2 { color: var(--accent-3); }
.token.alt-3 { color: var(--accent-4); }
.token.alt-4 { color: var(--accent-5); }
.token-empty { font-size: .8rem; color: var(--faint); }
.tok-ids {
  padding: .55rem .7rem;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: .67rem;
  line-height: 1.6;
  color: var(--faint);
  word-break: break-all;
}

/* ---------- Embeddings ---------- */
.embed-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 1rem;
}
.embed-visual { min-width: 0; }
.embed-canvas-wrap {
  position: relative;
  height: clamp(330px, 44vw, 470px);
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 42%, var(--surface-2), transparent 70%),
    var(--bg-2);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.embed-canvas-wrap:active { cursor: grabbing; }
#embed-canvas { width: 100%; height: 100%; }
.embed-tip {
  position: absolute;
  left: 0; top: 0;
  z-index: 3;
  display: none;
  transform: translate(-50%, -140%);
  padding: .3rem .55rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: .67rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-soft);
}
.embed-badge {
  position: absolute;
  right: .7rem;
  bottom: .6rem;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: .59rem;
  letter-spacing: .03em;
  color: var(--faint);
  pointer-events: none;
}
.embed-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem .95rem;
  margin-top: .65rem;
  font-size: .71rem;
  color: var(--muted);
}
.embed-legend span { display: flex; align-items: center; gap: .35rem; }
.embed-legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--swatch); flex: none; }
.embed-side {
  align-self: start;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  min-width: 0;
}
.embed-word {
  font-family: var(--font-display);
  font-size: 2.05rem;
  line-height: 1;
  color: var(--ink);
  margin: .35rem 0 .15rem;
  overflow-wrap: anywhere;
}
.embed-cat {
  font-family: var(--font-mono);
  font-size: .65rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.embed-neighbors-label { margin: 1rem 0 .25rem; font-size: .73rem; color: var(--faint); }
.embed-neighbors { display: flex; flex-direction: column; }
.embed-neighbors li {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  padding: .25rem 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--ink-soft);
}
.embed-neighbors li span:last-child { color: var(--faint); }
.embed-side .demo-note { margin-top: auto; padding-top: 1rem; }
.word-picker { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: 1rem; }
.word-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .15rem;
  padding: .26rem .4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
}
.word-group-label {
  margin-right: .2rem;
  font-family: var(--font-mono);
  font-size: .56rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
}
.word-btn {
  padding: .2rem .4rem;
  border-radius: 5px;
  font-size: .73rem;
  color: var(--muted);
  transition: color .2s, background .2s;
}
.word-btn:hover { color: var(--ink); background: var(--surface-3); }
.word-btn[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-soft); }
.fallback { margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.fallback summary { cursor: pointer; font-size: .78rem; color: var(--muted); }
.fallback summary:hover { color: var(--ink); }
.fallback-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .8rem;
  margin-top: .8rem;
  font-size: .78rem;
  color: var(--muted);
}
.fallback-grid strong { display: block; margin-bottom: .25rem; color: var(--accent-text); font-weight: 500; }

/* ---------- Neurona ---------- */
.neuron-layout {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 1.6rem;
  align-items: start;
}
.neuron-visual {
  min-width: 0;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-2);
}
.neuron-output {
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 7vw, 4.5rem);
  line-height: .9;
  color: var(--accent-text);
  margin: .35rem 0 .2rem;
  font-variant-numeric: tabular-nums;
}
.neuron-state {
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.meter { height: 6px; margin-top: 1rem; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-4));
  transition: width .3s var(--ease);
}
.curve-wrap { height: 172px; margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--line); }
#neuron-curve { width: 100%; height: 100%; }
.neuron-controls { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }
.neuron-controls fieldset { border: 0; padding: 0; margin: 0; }
.neuron-controls legend { margin-bottom: .5rem; padding: 0; }
.weights legend { margin-bottom: .4rem; }
.w-row {
  display: grid;
  grid-template-columns: 2.7rem minmax(0, 1fr) 3rem;
  align-items: center;
  gap: .65rem;
}
.w-row label { font-family: var(--font-mono); font-size: .73rem; color: var(--muted); }
.w-row output {
  font-family: var(--font-mono);
  font-size: .76rem;
  color: var(--accent-text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.w-row input { min-width: 0; }
.w-row--bias { padding-top: .9rem; border-top: 1px solid var(--line); }
.neuron-controls .segmented { margin-top: .15rem; }

/* ---------- Diagrama de red ---------- */
.net-panel {
  margin-top: 2rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.net-diagram { width: 100%; max-width: 660px; height: auto; margin: .5rem auto 0; }
.net-links path { fill: none; stroke: var(--line-strong); stroke-width: 1.1; }
.net-nodes circle { fill: var(--surface-2); stroke: var(--accent); stroke-width: 1.6; }
.net-nodes circle:nth-child(n+4):nth-child(-n+7) { stroke: var(--accent-4); }
.net-nodes circle:nth-child(n+8) { stroke: var(--accent-2); }
.net-labels text {
  fill: var(--faint);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: .08em;
  text-anchor: middle;
  text-transform: uppercase;
}
.net-caption { margin-top: .5rem; text-align: center; font-size: .77rem; color: var(--faint); }

/* ---------- Atención ---------- */
.sent-switch { display: flex; flex-wrap: wrap; gap: .3rem; }
.sent-btn {
  padding: .34rem .62rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .7rem;
  line-height: 1.3;
  transition: color .2s, border-color .2s, background .2s;
}
.sent-btn:hover { color: var(--ink); }
.sent-btn[aria-pressed="true"] {
  color: var(--accent-text);
  border-color: rgba(var(--accent-rgb), .4);
  background: var(--accent-soft);
}
.attn-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: .38rem;
  padding: .9rem;
  margin-bottom: .8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
}
.attn-token {
  padding: .32rem .55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: .84rem;
  transition: background .25s, border-color .25s, transform .2s, color .2s;
}
.attn-token:hover { transform: translateY(-2px); }
.attn-token[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.attn-token[data-heat] {
  background: rgba(var(--accent-rgb), calc(.05 + var(--heat) * .34));
  border-color: rgba(var(--accent-rgb), calc(.12 + var(--heat) * .4));
}
.attn-readout {
  min-height: 1.5em;
  margin-bottom: .95rem;
  font-size: .91rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.attn-readout strong { color: var(--accent-text); font-weight: 500; }
.attn-hint { margin: -.45rem 0 .9rem; }
.attn-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll-hint {
  display: none;
  margin: .45rem 0 0;
  text-align: right;
  font-family: var(--font-mono);
  font-size: .6rem;
  color: var(--faint);
}
@media (max-width: 820px) {
  .scroll-hint { display: block; }
}
.attn-table { width: 100%; font-family: var(--font-mono); font-size: .69rem; }
.attn-table caption {
  caption-side: top;
  padding: 0 0 .6rem;
  text-align: left;
  font-size: .7rem;
  color: var(--faint);
}
.attn-table th, .attn-table td {
  padding: .34rem .45rem;
  border: 1px solid var(--line);
  text-align: center;
}
.attn-table thead th {
  color: var(--muted);
  font-weight: 500;
  font-size: .61rem;
  white-space: nowrap;
  background: var(--surface-2);
}
.attn-table tbody th {
  color: var(--accent-text);
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}
.attn-cell { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Generación ---------- */
.gen-layout { display: grid; grid-template-columns: 1fr 1.05fr; gap: 1.5rem; }
.gen-controls { display: flex; flex-direction: column; gap: .95rem; min-width: 0; }
.candidates {
  display: flex;
  flex-direction: column;
  gap: .28rem;
  padding: .65rem .7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
}
.cand-row {
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr) 2.7rem;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-mono);
  font-size: .7rem;
  transition: opacity .2s;
}
.cand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
.cand-track { height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.cand-fill {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-4));
  transition: width .25s var(--ease);
}
.cand-pct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.cand-row.is-filtered { opacity: .32; }
.gen-visual { display: flex; flex-direction: column; gap: .85rem; min-width: 0; }
.gen-chart-wrap {
  height: 252px;
  padding: .55rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
}
#gen-chart { width: 100%; height: 100%; }
.gen-output-wrap {
  padding: .95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.gen-output-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .55rem; }
.gen-output {
  min-height: 2.6em;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.8vw, 1.65rem);
  line-height: 1.35;
  color: var(--ink);
}
.gen-output .last { color: var(--accent-text); animation: token-in .45s var(--ease); }
@keyframes token-in { from { opacity: 0; filter: blur(2px); } }

/* ---------- Bucle de entrenamiento ---------- */
.loop {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .75rem;
  margin-bottom: 1.8rem;
}
.loop li {
  position: relative;
  padding: .95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.loop li:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -.62rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  padding: 0 .1rem;
  background: var(--bg);
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: .8rem;
}
.loop-num { font-family: var(--font-mono); font-size: .61rem; letter-spacing: .1em; color: var(--accent-text); }
.loop strong { display: block; margin: .3rem 0 .2rem; font-size: .93rem; }
.loop p { font-size: .78rem; line-height: 1.5; color: var(--muted); }

/* ---------- Entrenamiento ---------- */
.train-layout { display: grid; grid-template-columns: 1.15fr .85fr; gap: 1.5rem; align-items: start; }
.train-visual { min-width: 0; }
.train-canvas-wrap {
  height: clamp(260px, 32vw, 340px);
  padding: .55rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
}
#loss-canvas { width: 100%; height: 100%; }
.train-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .45rem;
  margin-top: .7rem;
}
.train-stats > div {
  min-width: 0;
  padding: .45rem .55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.stat-label {
  display: block;
  font-family: var(--font-mono);
  font-size: .56rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
}
.train-stats strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: .83rem;
  font-weight: 500;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.train-controls { display: flex; flex-direction: column; gap: .95rem; }
.train-status { min-height: 2.7em; font-size: .84rem; line-height: 1.55; color: var(--muted); }
.train-controls .plain { margin: .2rem 0 0; }

/* ---------- Acordeón del pipeline ---------- */
.acc { max-width: 900px; margin: 0 auto; border-top: 1px solid var(--line-strong); }
.acc-item { border-bottom: 1px solid var(--line); }
.acc-trigger {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1.1rem .35rem;
  text-align: left;
  color: var(--ink);
}
.acc-index { flex: none; width: 1.7rem; font-family: var(--font-mono); font-size: .66rem; color: var(--accent-text); }
.acc-text { display: flex; flex: 1; flex-direction: column; gap: .12rem; min-width: 0; }
.acc-title { font-size: .99rem; font-weight: 600; letter-spacing: -.01em; transition: color .2s; }
.acc-trigger:hover .acc-title { color: var(--accent-text); }
.acc-sub { font-size: .81rem; font-weight: 400; color: var(--muted); }
.acc-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  transition: transform .3s var(--ease), color .2s, border-color .2s;
}
.acc-icon .icon { width: 14px; height: 14px; }
.acc-trigger[aria-expanded="true"] .acc-icon {
  transform: rotate(45deg);
  color: var(--accent-text);
  border-color: var(--accent);
}
.acc-panel {
  padding: 0 3rem 1.2rem;
  font-size: .89rem;
  line-height: 1.7;
  color: var(--muted);
}
.acc-panel p + p { margin-top: .55rem; }
.acc-panel .tech-only { padding-left: .8rem; border-left: 2px solid var(--line); }

/* ---------- Tabs y matemática ---------- */
.math-essential {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  margin: 1.2rem 0 0;
  padding: clamp(1.1rem, 3vw, 1.5rem);
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
}
.math-essential > div { max-width: 62ch; }
.math-essential p:last-child {
  margin-top: .4rem;
  font-size: .92rem;
  line-height: 1.65;
  color: var(--muted);
}
.tabs {
  display: flex;
  gap: .15rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: .68rem .9rem;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: .83rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color .2s, border-color .2s;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent-text); }
.tab-panel[hidden] { display: none; }
.math-layout {
  display: grid;
  grid-template-columns: .92fr 1.08fr;
  gap: 1.5rem;
  align-items: start;
}
.steps { display: flex; flex-direction: column; gap: .32rem; }
.step {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  width: 100%;
  padding: .62rem .7rem;
  border: 1px solid transparent;
  border-radius: 10px;
  text-align: left;
  color: var(--muted);
  transition: background .2s, border-color .2s, color .2s;
}
.step:hover { background: var(--surface-2); color: var(--ink); }
.step[aria-pressed="true"] {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
}
.step-num {
  flex: none;
  margin-top: .15rem;
  padding: .12rem .3rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: .6rem;
}
.step strong { display: block; font-size: .84rem; font-weight: 600; color: inherit; }
.step small { display: block; margin-top: .1rem; font-size: .72rem; line-height: 1.45; color: var(--muted); }
.math-visual {
  min-width: 0;
  min-height: 180px;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
}
.math-visual .mono-label { margin-bottom: .6rem; }
.vec-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; }
.vec-item { display: flex; flex-direction: column; align-items: center; gap: .2rem; min-width: 0; }
.vec-label { font-family: var(--font-mono); font-size: .56rem; color: var(--faint); white-space: nowrap; }
.vec-row { display: flex; flex-wrap: wrap; gap: .28rem; }
.vec {
  min-width: 2.9rem;
  padding: .26rem .38rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-size: .68rem;
  text-align: center;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.vec.vq { color: var(--accent-4); border-color: color-mix(in srgb, var(--accent-4) 32%, transparent); }
.vec.vk { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 32%, transparent); }
.vec.vv { color: var(--accent-3); border-color: color-mix(in srgb, var(--accent-3) 32%, transparent); }
.vec.vs { color: var(--ink-soft); }
.vec.vo { color: var(--accent-text); border-color: rgba(var(--accent-rgb), .32); background: var(--accent-soft); }
.qkv-rows { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.qkv-line { display: grid; grid-template-columns: 2rem minmax(0, 1fr); align-items: center; gap: .45rem; }
.qkv-line > span { font-family: var(--font-mono); font-size: .64rem; color: var(--faint); }
.qkv-line .vec-row { flex-wrap: nowrap; overflow-x: auto; }
.cos-layout { display: grid; grid-template-columns: 1.1fr .9fr; gap: 1.5rem; align-items: center; }
.cos-canvas-wrap {
  height: 265px;
  padding: .55rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
}
#cos-canvas { width: 100%; height: 100%; }
.cos-controls { display: flex; flex-direction: column; gap: .8rem; min-width: 0; }
.cos-value { font-family: var(--font-mono); font-size: 1.05rem; color: var(--muted); }
.cos-value strong { font-size: 1.45rem; color: var(--accent-text); font-weight: 500; }

/* ---------- Forward pass ---------- */
.fwd-canvas-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
}
#fwd-canvas { display: block; width: 100%; }
.fwd-legend { display: flex; flex-wrap: wrap; gap: .45rem 1rem; margin: .7rem 0; }
.fwd-legend span { display: flex; align-items: center; gap: .35rem; font-family: var(--font-mono); font-size: .62rem; color: var(--muted); }
.fwd-legend i { width: 7px; height: 7px; border-radius: 2px; background: var(--swatch); flex: none; }
.fwd-controls { display: flex; flex-wrap: wrap; gap: .5rem; margin: .3rem 0 1rem; }
.fwd-steps { display: flex; flex-wrap: wrap; gap: .28rem; }
.fwd-steps li {
  padding: .24rem .44rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: .6rem;
  transition: color .2s, border-color .2s, background .2s;
}
.fwd-steps li.is-done { color: var(--ink-soft); border-color: var(--line-strong); }
.fwd-steps li.is-active { color: var(--accent-text); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Modelos ---------- */
.models-table { min-width: 790px; }
.model-name { font-weight: 600; color: var(--ink); }
.model-org { display: block; margin-top: .08rem; font-family: var(--font-mono); font-size: .6rem; color: var(--faint); }
.badge {
  display: inline-block;
  padding: .14rem .4rem;
  border: 1px solid;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: .58rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-open {
  color: var(--accent-text);
  border-color: rgba(var(--accent-rgb), .3);
  background: var(--accent-soft);
}
.badge-closed {
  color: var(--accent-2);
  border-color: color-mix(in srgb, var(--accent-2) 30%, transparent);
  background: color-mix(in srgb, var(--accent-2) 8%, transparent);
}
.cell-mono {
  font-family: var(--font-mono);
  font-size: .74rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cell-ctx { font-family: var(--font-mono); color: var(--accent-text); }

/* ---------- Quiz ---------- */
.quiz {
  margin-top: 2.4rem;
  padding: clamp(1.1rem, 3vw, 1.6rem);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.quiz-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.15rem; }
.quiz-head h3 { margin-top: .2rem; font-size: 1.15rem; }
.quiz-item {
  margin-bottom: .55rem;
  padding: .95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  transition: border-color .25s;
}
.quiz-q { margin-bottom: .8rem; font-size: .9rem; line-height: 1.55; color: var(--ink); }
.quiz-num { margin-right: .35rem; font-family: var(--font-mono); font-size: .66rem; color: var(--accent-text); }
.quiz-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.quiz-actions button {
  padding: .4rem .75rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: .77rem;
  transition: color .2s, border-color .2s;
}
.quiz-actions button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-text); }
.quiz-actions button:disabled { opacity: .45; cursor: default; }
.quiz-feedback {
  margin-top: .8rem;
  padding: .65rem .8rem;
  border-left: 2px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--accent-soft);
  font-size: .8rem;
  line-height: 1.6;
  color: var(--ink-soft);
}
.quiz-item.is-correct { border-color: rgba(var(--accent-rgb), .4); }
.quiz-item.is-wrong { border-color: color-mix(in srgb, var(--accent-2) 45%, transparent); }
.quiz-item.is-wrong .quiz-feedback { border-left-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 7%, transparent); }
.quiz-score { margin-top: .8rem; font-family: var(--font-mono); font-size: .7rem; color: var(--muted); }
.checklist {
  margin-top: 2rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}
.checklist ul { display: flex; flex-direction: column; gap: .45rem; margin-top: .7rem; }
.checklist li { position: relative; padding-left: 1.3rem; font-size: .85rem; line-height: 1.55; color: var(--muted); }
.checklist li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: .75rem;
}

/* ---------- Comparativas y principios ---------- */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.compare-col { padding: 1.2rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.compare-col--bad { border-left: 2px solid var(--accent-2); }
.compare-col--good { border-left: 2px solid var(--accent); }
.compare-col .mono-label { margin-bottom: .55rem; }
.compare-col--bad .mono-label { color: var(--accent-2); }
.compare-col--good .mono-label { color: var(--accent-text); }
.compare-quote {
  margin-bottom: .55rem;
  font-family: var(--font-display);
  font-size: 1.22rem;
  line-height: 1.35;
  color: var(--ink);
}
.compare-why { font-size: .79rem; line-height: 1.55; color: var(--muted); }
.principles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: .9rem;
  margin: 1.5rem 0 2rem;
}
.principle { padding-top: .75rem; border-top: 1px solid var(--line-strong); }
.principle-num { font-family: var(--font-mono); font-size: .6rem; color: var(--accent-text); }
.principle h3 { margin: .25rem 0; font-size: .93rem; }
.principle p { font-size: .8rem; line-height: 1.55; color: var(--muted); }

/* ---------- Armador de prompts ---------- */
.pb-layout { display: grid; grid-template-columns: 1.05fr .95fr; gap: 1.4rem; }
.pb-fields { display: flex; flex-direction: column; gap: .9rem; min-width: 0; }
.pb-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.pb-preview { display: flex; flex-direction: column; gap: .55rem; min-width: 0; }
.pb-preview-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.pb-output {
  flex: 1;
  min-height: 265px;
  background: var(--bg-2);
  font-family: var(--font-mono);
  font-size: .76rem;
  line-height: 1.65;
}
.pb-output:focus { border-color: var(--accent); }
.pb-preview .demo-note { margin-top: 0; }

/* ---------- Glosario ---------- */
.glossary-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .55rem;
  margin-bottom: 1.3rem;
}
.search-wrap { position: relative; flex: 1; min-width: 235px; }
.search-wrap .icon {
  position: absolute;
  left: .85rem;
  top: 50%;
  width: 16px; height: 16px;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
}
.search-input { padding-left: 2.35rem; border-radius: 10px; }
.glossary-filters { display: flex; gap: .28rem; }
.glossary-filters button {
  padding: .4rem .65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .72rem;
  transition: color .2s, border-color .2s, background .2s;
}
.glossary-filters button[aria-pressed="true"] {
  color: var(--accent-text);
  border-color: rgba(var(--accent-rgb), .35);
  background: var(--accent-soft);
}
.glossary-count { margin-left: auto; font-family: var(--font-mono); font-size: .66rem; color: var(--faint); }
.terms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .7rem; }
.term-card {
  padding: .95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.term-card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.term-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.term-name { font-family: var(--font-mono); font-size: .82rem; font-weight: 500; color: var(--accent-text); }
.term-en { font-family: var(--font-mono); font-size: .58rem; color: var(--faint); white-space: nowrap; }
.term-def { margin-top: .38rem; font-size: .8rem; line-height: 1.6; color: var(--muted); }
.term-tag {
  display: inline-block;
  margin-top: .5rem;
  padding: .1rem .35rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: .54rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
}
.term-empty {
  grid-column: 1 / -1;
  padding: 2rem;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  text-align: center;
  font-size: .88rem;
  color: var(--faint);
}

/* ---------- Misiones ---------- */
.missions-fab {
  position: fixed;
  right: calc(1rem + env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .75rem .55rem .55rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-family: var(--font-sans);
  font-size: .78rem;
  font-weight: 600;
  line-height: 1;
  visibility: visible;
  opacity: 1;
  transition: opacity .25s var(--ease), transform .25s var(--ease), border-color .25s, box-shadow .25s;
}
.missions-fab.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}
.missions-fab:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}
.missions-fab-icon {
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.missions-fab-icon .icon { width: 16px; height: 16px; }
.missions-fab-count {
  padding: .16rem .4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: .64rem;
  line-height: 1;
}
.missions-fab.is-complete {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
}
.missions-fab.is-complete .missions-fab-icon {
  background: var(--accent);
  color: var(--accent-ink);
}
.missions-fab.is-pulse .missions-fab-icon {
  animation: mission-pulse 1.4s var(--ease) 2;
}
@keyframes mission-pulse {
  50% { transform: scale(1.14); box-shadow: 0 0 0 8px var(--accent-soft); }
}

.missions-card { width: min(900px, 92vw); }
.missions-progress {
  margin-bottom: 1.4rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}
.missions-progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .5rem;
}
#missions-progress-text {
  font-family: var(--font-mono);
  font-size: .74rem;
  color: var(--accent-text);
}
.missions-track {
  height: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.missions-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-4));
  transition: width .5s var(--ease);
}
.missions-progress .demo-note { margin-top: .55rem; }
.missions-list { display: flex; flex-direction: column; gap: 1.2rem; }
.missions-group h3 {
  margin: 0 0 .55rem;
  font-family: var(--font-mono);
  font-size: .63rem;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent-text);
}
.missions-group-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
}
.mission-item {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.mission-item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.mission-item.is-done {
  border-color: rgba(var(--accent-rgb), .38);
  background: linear-gradient(90deg, var(--accent-soft), transparent 85%);
}
.mission-icon {
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
}
.mission-item.is-done .mission-icon {
  background: var(--accent);
  color: var(--accent-ink);
}
.mission-icon .icon { width: 16px; height: 16px; }
.mission-body { flex: 1; min-width: 0; }
.mission-body h4 {
  margin: 0 0 .12rem;
  font-size: .85rem;
  font-weight: 600;
  line-height: 1.3;
}
.mission-body p {
  margin: 0;
  font-size: .74rem;
  line-height: 1.45;
  color: var(--muted);
}
.mission-status {
  display: inline-block;
  margin-top: .3rem;
  font-family: var(--font-mono);
  font-size: .6rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.mission-item.is-done .mission-status { color: var(--accent-text); }
.mission-go {
  align-self: center;
  padding: .2rem .45rem;
  border: 1px solid rgba(var(--accent-rgb), .3);
  border-radius: 999px;
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: .6rem;
  text-decoration: none;
  white-space: nowrap;
}
.mission-go:hover { background: var(--accent-soft); }
.missions-badge {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  margin-top: 1.5rem;
  padding: 1.1rem;
  border: 1px solid rgba(var(--accent-rgb), .38);
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent-soft), transparent 80%);
}
.missions-badge[hidden], .missions-locked[hidden] { display: none; }
.missions-badge-head {
  display: flex;
  align-items: center;
  gap: .8rem;
}
.missions-medal {
  width: 52px; height: 52px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 6px var(--accent-soft);
}
.missions-medal .icon { width: 26px; height: 26px; }
.missions-badge h3 {
  margin: .15rem 0 .1rem;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 400;
  line-height: 1;
  color: var(--ink);
}
.missions-badge > p { font-size: .82rem; line-height: 1.55; color: var(--muted); }
.missions-badge .field-label { margin: .35rem 0 .25rem; }
.missions-badge .btn-row { margin-top: .2rem; }
.missions-locked { margin-top: 1.2rem; }
.missions-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
#missions-reset.is-armed {
  color: var(--danger);
  border-color: var(--danger);
}
.mission-toast {
  position: fixed;
  left: 50%;
  bottom: calc(5.2rem + env(safe-area-inset-bottom));
  z-index: 95;
  max-width: min(420px, 90vw);
  padding: .75rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: .84rem;
  line-height: 1.45;
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.mission-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.mission-toast strong { color: var(--accent-text); font-weight: 600; }

@media (max-width: 700px) {
  .missions-group-grid { grid-template-columns: 1fr; }
  .missions-card { width: 94vw; }
  .missions-badge-head { align-items: flex-start; }
}
@media (max-width: 560px) {
  .missions-fab-label { display: none; }
  .missions-fab { padding: .5rem .6rem .5rem .5rem; }
  .missions-badge .btn-row .btn { width: 100%; }
}

/* ---------- Docentes ---------- */
.dialog-docente {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}
.dialog-docente > div:first-child { max-width: 52ch; }
.dialog-docente .demo-note { margin-top: .25rem; }
.dialog-docente-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.footer-docente {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  margin-top: 1.4rem;
  font-size: .8rem;
  color: var(--muted);
}
.footer-docente a,
.footer-docente button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.footer-docente a:hover,
.footer-docente button:hover { text-decoration: underline; }
.footer-docente button { font-weight: 600; }

/* ---------- Modo Aula / Proyector ---------- */
html[data-classroom="on"] { --max: 1320px; }
html[data-classroom="on"] body {
  font-size: 1.12rem;
  padding-bottom: 110px;
}
html[data-classroom="on"] .main-nav,
html[data-classroom="on"] .header-actions .level-switch,
html[data-classroom="on"] .header-actions .index-btn { display: none !important; }
html[data-classroom="on"] .missions-fab,
html[data-classroom="on"] .rail,
html[data-classroom="on"] .scroll-cue,
html[data-classroom="on"] .mission-toast { display: none !important; }
html[data-classroom="on"] .will-reveal {
  opacity: 1;
  transform: none;
  transition: none;
}
html[data-classroom="on"] .hero { min-height: 80vh; }
html[data-classroom="on"] .hero h1 { font-size: clamp(4rem, 9vw, 8.5rem); }
html[data-classroom="on"] .chapter {
  padding-top: clamp(4rem, 6vw, 6rem);
  padding-bottom: clamp(4rem, 6vw, 6rem);
}
html[data-classroom="on"] .chapter h2 { font-size: clamp(2.7rem, 5vw, 4.8rem); }
html[data-classroom="on"] .lead { font-size: 1.2rem; max-width: 64ch; }
html[data-classroom="on"] .card p,
html[data-classroom="on"] .plain p:last-child,
html[data-classroom="on"] .demo-note,
html[data-classroom="on"] .section-note { font-size: 1rem; }
html[data-classroom="on"] .card h3 { font-size: 1.08rem; }
html[data-classroom="on"] #hero-canvas { opacity: .3; }
html[data-classroom="on"][data-theme="dark"] {
  --muted: #C6D5CD;
  --faint: #A7B8AF;
  --line-strong: rgba(213, 255, 240, .28);
}
html[data-classroom="on"][data-theme="light"] {
  --muted: #2F3D35;
  --faint: #445249;
  --line-strong: rgba(20, 35, 28, .32);
}

.classroom-bar {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 120;
  display: flex;
  align-items: center;
  gap: .45rem;
  width: min(920px, calc(100vw - 2rem));
  padding: .55rem;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}
.classroom-bar[hidden],
.classroom-notes[hidden] { display: none; }
.classroom-status {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: .05rem;
  min-width: 0;
}
.classroom-status .mono-label { font-size: .58rem; }
.classroom-status .mono-label b { color: var(--accent-text); font-weight: 600; }
.classroom-status strong {
  overflow: hidden;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.classroom-nav,
.classroom-notes-btn,
.classroom-exit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  flex: none;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: .72rem;
  font-weight: 600;
  transition: color .2s, border-color .2s, background .2s;
}
.classroom-nav { width: 40px; }
.classroom-nav .icon,
.classroom-notes-btn .icon,
.classroom-exit .icon { width: 17px; height: 17px; }
.classroom-nav:hover:not(:disabled),
.classroom-notes-btn:hover,
.classroom-exit:hover {
  color: var(--accent-text);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.classroom-nav:disabled { opacity: .35; cursor: not-allowed; }
#classroom-prev .icon { transform: rotate(180deg); }
.classroom-notes-btn { padding: 0 .6rem; }
.classroom-notes-btn[aria-pressed="true"] {
  color: var(--accent-text);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.classroom-exit {
  padding: 0 .6rem;
  color: var(--accent-text);
  border-color: rgba(var(--accent-rgb), .35);
}
.classroom-notes {
  position: fixed;
  left: 50%;
  bottom: calc(5.6rem + env(safe-area-inset-bottom));
  z-index: 119;
  width: min(760px, calc(100vw - 2rem));
  max-height: 45vh;
  overflow: auto;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}
.classroom-notes .mono-label {
  margin-bottom: .35rem;
  color: var(--accent-text);
}
.classroom-question {
  margin-bottom: .5rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.45rem;
  line-height: 1.25;
}
.classroom-tip {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.55;
}
.classroom-shortcuts {
  margin-top: .7rem;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: .62rem;
}

@media (max-width: 600px) {
  .classroom-bar {
    bottom: calc(.5rem + env(safe-area-inset-bottom));
    width: calc(100vw - 1rem);
    gap: .3rem;
    padding: .4rem;
  }
  .classroom-status strong { font-size: .78rem; }
  .classroom-notes-btn,
  .classroom-exit { width: 38px; padding: 0; }
  .classroom-notes-btn span,
  .classroom-exit span { display: none; }
  .classroom-notes {
    bottom: calc(4.6rem + env(safe-area-inset-bottom));
    width: calc(100vw - 1rem);
    max-height: 50vh;
  }
  .classroom-question { font-size: 1.2rem; }
  html[data-classroom="on"] body { padding-bottom: 96px; }
}

/* ---------- Minijuego: Entrená una neurona ---------- */
.game-intro {
  max-width: 72ch;
  margin-top: 2.8rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.game-intro .mono-label { margin-bottom: .4rem; color: var(--accent-3); }
.game-intro h3 {
  margin-bottom: .5rem;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  font-weight: 400;
  line-height: 1.05;
}
.game-intro p:last-child {
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.65;
}
.game-demo {
  margin-top: 1.2rem;
  border-color: rgba(var(--accent-rgb), .25);
}
.game-demo::before { background: linear-gradient(90deg, var(--accent-3), transparent 65%); }
.game-layout {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 1.2rem;
  align-items: start;
}
.game-visual { min-width: 0; }
.game-canvas-wrap {
  height: clamp(300px, 38vw, 420px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-2);
}
#game-canvas { display: block; width: 100%; height: 100%; }
.game-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem 1rem;
  margin-top: .6rem;
  color: var(--muted);
  font-size: .72rem;
}
.game-legend span { display: flex; align-items: center; gap: .35rem; }
.game-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--swatch); flex: none; }
.game-square { width: 9px; height: 9px; border-radius: 2px; background: var(--swatch); flex: none; }
.game-ring { width: 9px; height: 9px; border: 2px solid var(--danger); border-radius: 50%; flex: none; }
.game-visual .demo-note { margin-top: .55rem; }
.game-panel { display: flex; flex-direction: column; gap: .75rem; min-width: 0; }
.game-score { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.game-accuracy {
  display: flex;
  align-items: baseline;
  gap: .55rem;
  margin-top: .2rem;
  color: var(--accent-text);
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5vw, 3.4rem);
  line-height: 1;
}
.game-accuracy strong { font-weight: 400; }
.game-accuracy span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .02em;
}
.game-meter {
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: var(--surface-3);
}
.game-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-4));
  transition: width .3s var(--ease);
}
.game-status {
  min-height: 2.6em;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.55;
}
.game-controls { display: flex; flex-direction: column; gap: .55rem; }
.game-controls .control { gap: .3rem; }
.game-controls .control > label { font-size: .66rem; }
.game-secondary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
}
.game-secondary .demo-note { font-size: .7rem; }
.game-demo.is-won {
  border-color: rgba(var(--accent-rgb), .55);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}
.game-demo.is-won .game-accuracy { color: var(--accent-text); }

@media (max-width: 900px) {
  .game-layout { grid-template-columns: 1fr; }
  .game-canvas-wrap { height: 320px; }
}
@media (max-width: 560px) {
  .game-canvas-wrap { height: 280px; }
  .game-secondary .demo-note { width: 100%; }
  .game-accuracy span { font-size: .62rem; }
}

/* ---------- Fuentes ---------- */
.sources {
  padding: clamp(3.5rem, 7vw, 5.5rem) var(--gutter);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.sources-inner { max-width: var(--max); margin: 0 auto; }
.sources-head { max-width: 700px; margin-bottom: 1.8rem; }
.sources-head h2 { margin: .45rem 0 .7rem; font-size: clamp(1.85rem, 4vw, 2.8rem); line-height: 1.02; }
.source-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .55rem; }
.source-list a {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: .15rem .8rem;
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-decoration: none;
  transition: border-color .2s, transform .2s;
}
.source-list a:hover { border-color: var(--accent); transform: translateY(-2px); }
.source-list a span { font-size: .87rem; font-weight: 500; color: var(--ink); }
.source-list a small { grid-column: 1; font-size: .71rem; line-height: 1.4; color: var(--muted); }
.source-list .icon { grid-row: 1 / 3; grid-column: 2; width: 15px; height: 15px; color: var(--faint); }
.source-list a:hover .icon { color: var(--accent-text); }

/* ---------- Responsive de componentes ---------- */
@media (max-width: 1000px) {
  .tok-layout,
  .neuron-layout,
  .gen-layout,
  .train-layout,
  .pb-layout,
  .math-layout,
  .embed-layout { grid-template-columns: 1fr; }
  .embed-side { flex-direction: column; }
  .embed-canvas-wrap { height: clamp(300px, 52vw, 420px); }
  .train-stats { grid-template-columns: repeat(4, 1fr); }
  .gen-chart-wrap { height: 230px; }
}
@media (max-width: 800px) {
  .flow { grid-template-columns: 1fr 1fr; }
  .flow li:nth-child(2)::after { display: none; }
  .flow li:nth-child(4)::after { display: none; }
  .loop { grid-template-columns: 1fr 1fr; }
  .loop li:nth-child(2)::after { display: none; }
  .loop li:nth-child(4)::after { display: none; }
  .compare { grid-template-columns: 1fr; }
  .cos-layout { grid-template-columns: 1fr; }
  .cos-canvas-wrap { height: 240px; }
  .acc-panel { padding-left: 2.6rem; padding-right: .5rem; }
  .term-head { flex-wrap: wrap; }
  .glossary-count { margin-left: 0; width: 100%; }
  .train-stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .pyramid li { width: 100%; }
  .flow { grid-template-columns: 1fr; }
  .flow li::after { display: none !important; }
  .loop { grid-template-columns: 1fr; }
  .loop li::after { display: none !important; }
  .pred-options { grid-template-columns: 1fr; }
  .pb-row { grid-template-columns: 1fr; }
  .vec-grid { grid-template-columns: repeat(3, 1fr); }
  .fwd-steps { gap: .22rem; }
  .fwd-steps li { font-size: .56rem; }
  .quiz-head { flex-direction: column; }
  .acc-trigger { gap: .7rem; }
  .acc-sub { font-size: .76rem; }
  .embed-canvas-wrap { height: 300px; }
  .tok-stats #tok-ratio { width: 100%; margin-right: 0; }
}
