/* ═══════════════════════════════════════════════════════════════════════════
   Estudio Científico Pro · regiones de datos (B): gráfica, matriz y tabla
   Solo tokens de css/tokens.css. Modo oscuro: los tokens ya cambian.
   El único color que no es token es --trace: el color del TRAZO (dato de la
   curva, elegido por el usuario), que llega por variable en línea.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── comunes ─────────────────────────────────────────────────────────── */
.esci-plot, .esci-plot3d, .esci-matrix, .esci-table { font-family: var(--sans); font-size: var(--fs-ui); color: var(--ink); }
/* el atributo hidden debe ganar a cualquier display de estas reglas */
.esci-plot [hidden], .esci-plot3d [hidden], .esci-matrix [hidden], .esci-table [hidden] { display: none !important; }
.esci-plot .esci-btn, .esci-plot3d .esci-btn, .esci-matrix .esci-btn, .esci-table .esci-btn {
  min-width: 36px; min-height: 36px; padding: 0 8px; border-radius: var(--r-sm);
  border: 1px solid var(--key-line); background: var(--key); color: var(--ink-2);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 500 var(--fs-ui-sm) var(--sans); transition: background .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease);
}
.esci-plot .esci-btn:hover, .esci-plot3d .esci-btn:hover, .esci-matrix .esci-btn:hover, .esci-table .esci-btn:hover { background: var(--key-hover); border-color: var(--key-hover-line); color: var(--accent); }
.esci-plot .esci-btn:focus-visible, .esci-plot3d .esci-btn:focus-visible, .esci-matrix .esci-btn:focus-visible, .esci-table .esci-btn:focus-visible,
.esci-plot input:focus-visible, .esci-plot3d input:focus-visible, .esci-matrix input:focus-visible, .esci-table input:focus-visible,
.esci-plot select:focus-visible, .esci-plot3d select:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 1px; }
.esci-plot .esci-btn:disabled, .esci-plot3d .esci-btn:disabled, .esci-matrix .esci-btn:disabled, .esci-table .esci-btn:disabled { opacity: .45; cursor: default; }
.esci-plot .esci-btn.esci-on, .esci-plot3d .esci-btn.esci-on, .esci-matrix .esci-btn.esci-on, .esci-table .esci-btn.esci-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.esci-plot .esci-btn-text, .esci-plot3d .esci-btn-text { padding: 0 10px; }
.esci-plot input[type="text"], .esci-plot3d input[type="text"], .esci-matrix input[type="text"], .esci-table input[type="text"],
.esci-plot select, .esci-plot3d select {
  min-height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: 500 var(--fs-ui) var(--mono); box-sizing: border-box;
}
.esci-plot input[type="text"]:disabled, .esci-table input[type="text"]:disabled { background: var(--sunk); color: var(--ink-4); }
.esci-plot select, .esci-plot3d select { font-family: var(--sans); }
@media (pointer: coarse) {
  .esci-plot .esci-btn, .esci-plot3d .esci-btn, .esci-matrix .esci-btn, .esci-table .esci-btn,
  .esci-plot input[type="text"], .esci-plot3d input[type="text"], .esci-matrix input[type="text"], .esci-table input[type="text"],
  .esci-plot select, .esci-plot3d select { min-height: 40px; }
  .esci-plot .esci-plot-chk, .esci-plot3d .esci-plot-chk { min-height: 40px; }
}
/* avisos: icono cobre (parcial) o rojo (el trazo/columna no se pudo calcular) */
.esci-plot-warn, .esci-tb-warn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--r-pill); color: var(--warn); background: var(--warn-soft); cursor: help; flex: 0 0 auto; }
.esci-plot-warn.esci-plot-warn-bad { color: var(--bad); background: var(--bad-soft); }
.esci-mx-error, .esci-tb-error { margin: 6px 0 0; padding: 6px 10px; border-radius: var(--r-sm); background: var(--bad-soft); color: var(--bad); font-size: var(--fs-ui-sm); line-height: 1.35; display: flex; gap: 8px; align-items: flex-start; }
.esci-mx-error i, .esci-tb-error i { margin-top: 2px; }

/* ── GRÁFICA ─────────────────────────────────────────────────────────── */
.esci-plot { min-width: 240px; min-height: 180px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-md); box-shadow: var(--shadow-1); box-sizing: border-box; }
.esci-plot > .esci-body { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.esci-plot-head { display: flex; align-items: flex-start; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); background: var(--chassis); border-radius: var(--r-md) var(--r-md) 0 0; flex: 0 0 auto; }
.esci-plot-traces { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.esci-plot-tools { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; }
.esci-plot-row { display: flex; align-items: center; gap: 4px; position: relative; flex-wrap: wrap; }
.esci-plot-row-off { opacity: .55; }
.esci-plot-expr { flex: 1 1 96px; min-width: 70px; }
.esci-plot-expr2 { flex: 1 1 72px; min-width: 60px; }
.esci-plot-tipo { width: 118px; flex: 0 0 auto; }
.esci-plot-eye, .esci-plot-more { color: var(--ink-3); }
/* en una fila caben muchos mandos: 32 px es el mínimo cómodo (40 con el dedo) */
.esci-plot-row .esci-btn { min-width: 32px; padding: 0 4px; }
.esci-plot-row .esci-plot-warn { width: 24px; height: 24px; }
.esci-plot-varwrap { display: inline-flex; align-items: center; gap: 3px; color: var(--ink-4); font-size: var(--fs-label); }
.esci-plot-var { width: 40px; text-align: center; padding: 0 4px; }
.esci-plot-style { width: 96px; }
.esci-plot-color { width: 32px; min-width: 32px; padding: 0; position: relative; flex: 0 0 auto; }
.esci-plot-color::before { content: ''; width: 16px; height: 16px; border-radius: var(--r-pill); background: var(--trace); box-shadow: 0 0 0 1px var(--line-strong) inset; }
.esci-plot-del { color: var(--ink-4); }
.esci-plot-del:hover { color: var(--bad); }
.esci-plot-swatches { position: absolute; left: 0; top: 100%; z-index: 30; margin-top: 4px; padding: 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; width: 176px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-2); }
.esci-plot-sw { width: 30px; height: 30px; border-radius: var(--r-pill); border: 2px solid var(--surface); background: var(--trace); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; padding: 0; }
.esci-plot-sw.esci-on { box-shadow: 0 0 0 2px var(--accent); }
.esci-plot-swcustom { width: 30px; height: 30px; border: none; background: none; padding: 0; cursor: pointer; }
.esci-plot-stage { position: relative; flex: 1 1 auto; min-height: 0; }
.esci-plot-host { position: absolute; inset: 0; }
.esci-plot-host .ggl { min-height: 0; height: 100%; border-radius: 0 0 var(--r-md) var(--r-md); }
.esci-plot-sin-motor { padding: 12px; color: var(--bad); font-size: var(--fs-ui-sm); }
/* leyenda en HTML (KaTeX) sobre el lienzo; la de GGLAB queda apagada */
.esci-plot-legend { position: absolute; left: 54px; top: 12px; z-index: 4; pointer-events: none; display: flex; flex-direction: column; gap: 3px; padding: 6px 10px 6px 8px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-sm); opacity: .94; font-size: var(--fs-ui-sm); color: var(--ink); max-width: 60%; }
.esci-plot-legend-item { display: flex; align-items: center; gap: 8px; min-height: 18px; }
.esci-plot-legend-sw { width: 22px; height: 0; border-top: 2.5px solid var(--trace); flex: 0 0 auto; }
.esci-plot-legend-dash { border-top-style: dashed; }
.esci-plot-legend-dot { border-top-style: dotted; border-top-width: 3px; }
.esci-plot-legend-dashdot { border-top-style: dashed; }
.esci-plot-legend-tex .katex { font-size: 1.02em; }
/* panel de opciones (paleta) */
.esci-plot-panel { position: absolute; right: 10px; top: 10px; z-index: 6; width: 250px; max-height: calc(100% - 20px); overflow: auto; padding: 8px 10px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-2); display: flex; flex-direction: column; gap: 8px; }
.esci-plot-panel[hidden] { display: none; }
.esci-plot-panel-title { display: flex; align-items: center; justify-content: space-between; font: 600 var(--fs-label) var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.esci-plot-panel-grp { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding-top: 6px; border-top: 1px solid var(--line-soft); }
.esci-plot-chk { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; cursor: pointer; font-size: var(--fs-ui-sm); color: var(--ink-2); }
.esci-plot-chk input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.esci-plot-fld { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-ui-sm); color: var(--ink-3); }
.esci-plot-fld .esci-plot-txt { min-height: 32px; padding: 0 6px; }
/* el panel flotante «Vista» de GGLAB estorba en regiones pequeñas: se pliega solo */
.esci-plot .ggl-panel { transform: scale(.86); transform-origin: top right; }
.esci-plot .ggl-hint { left: 52px; bottom: 30px; }
.esci-plot:not(.esci-selected) .ggl-panel { display: none; }
.esci-plot:not(.esci-selected) .esci-plot-panel { display: none; }
.esci-plot3d:not(.esci-selected) .esci-plot-panel { display: none; }
/* panel de un trazo: a la izquierda, para no taparse con el de la gráfica */
.esci-plot-tpanel { right: auto; left: 10px; width: 268px; }
.esci-plot-fld-w { flex: 1 1 100%; }
.esci-plot-fld-w input[type="range"] { flex: 1 1 auto; min-width: 80px; accent-color: var(--accent); }
.esci-plot-fld-w b { font: 500 var(--fs-ui-sm) var(--mono); color: var(--ink-2); min-width: 30px; text-align: right; }
.esci-plot-nota { font-size: var(--fs-label); color: var(--ink-4); line-height: 1.4; flex: 0 0 auto; }
.esci-plot-piezas { flex-direction: column; align-items: stretch; }
.esci-plot-pieza { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 3px 0; border-bottom: 1px dashed var(--line-soft); }
.esci-plot-pieza input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.esci-plot-pieza .esci-plot-txt { min-height: 32px; padding: 0 6px; }

/* ── GRÁFICA 3D (Plotly bajo demanda) ────────────────────────────────── */
.esci-plot3d { min-width: 300px; min-height: 240px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-md); box-shadow: var(--shadow-1); box-sizing: border-box; }
.esci-plot3d > .esci-body { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.esci-p3d-host { border-radius: 0 0 var(--r-md) var(--r-md); overflow: hidden; }
.esci-p3d-estado { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  color: var(--ink-3); font-size: var(--fs-ui-sm); text-align: center; padding: 12px; pointer-events: none; }
.esci-p3d-estado i { font-size: 20px; color: var(--ink-4); }
.esci-p3d-aviso { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 8px 8px; padding: 6px 10px; border-radius: var(--r-sm);
  background: var(--bad-soft); color: var(--bad); font-size: var(--fs-ui-sm); line-height: 1.35; }
.esci-p3d-aviso .esci-btn { color: var(--bad); }
.esci-p3d-picker { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ── MATRIZ ──────────────────────────────────────────────────────────── */
.esci-matrix { min-width: 340px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-md); box-shadow: var(--shadow-1); padding: 6px 10px 8px; display: inline-block; box-sizing: border-box; }
/* ── cabecera de la matriz ────────────────────────────────────────────────
   Antes el nombre era una cajita de 60 px sin rótulo (no parecía escribible) y
   el tamaño solo se podía cambiar a golpe de «+» y «−», con DOS botones de
   menos idénticos. Ahora el nombre lleva su etiqueta y el tamaño se teclea. */
.esci-mx-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.esci-mx-lab { font: 600 var(--fs-label)/1 var(--sans); color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.esci-mx-name {
  width: 78px; min-height: 30px; padding: 0 8px; font-weight: 600; color: var(--define);
  border: 1px solid var(--define-line, var(--line)); border-radius: var(--r-sm); background: var(--define-bg, var(--surface-2));
}
.esci-mx-name:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.esci-mx-def { color: var(--ink-3); font-family: var(--mono); }
.esci-mx-dims { display: inline-flex; align-items: center; gap: 3px; }
.esci-mx-num {
  width: 46px; min-height: 30px; padding: 0 4px; text-align: center;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2);
  color: var(--ink); font: 500 var(--fs-ui)/1 var(--mono);
}
.esci-mx-num:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.esci-mx-por { color: var(--ink-3); font-family: var(--mono); }
.esci-mx-tools { display: flex; align-items: center; gap: 3px; margin-left: auto; }
.esci-mx-tools .esci-btn { min-width: 30px; min-height: 30px; }
.esci-mx-sep { width: 1px; align-self: stretch; margin: 2px 3px; background: var(--line); }
/* los botones de COLUMNA se distinguen de los de fila por el giro del icono:
   sin esto, «quitar fila» y «quitar columna» eran el mismo signo menos */
.esci-mx-tools .esci-btn.is-col i { transform: rotate(90deg); }
@media (pointer: coarse) { .esci-mx-tools .esci-btn, .esci-mx-num, .esci-mx-name { min-height: 38px; } }

/* rejilla para elegir el tamaño con el ratón */
.esci-mx-pop {
  position: fixed; z-index: 1400; padding: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-3);
}
.esci-mx-pop-info { text-align: center; font: 600 var(--fs-ui-sm)/1.6 var(--mono); color: var(--ink-2); margin-bottom: 4px; }
.esci-mx-pop-grid { display: grid; gap: 2px; }
.esci-mx-pop-c { width: 16px; height: 16px; padding: 0; border: 1px solid var(--line); border-radius: 2px; background: var(--surface-2); cursor: pointer; }
.esci-mx-pop-c.is-on { background: var(--accent); border-color: var(--accent); }

/* Gauss-Jordan paso a paso */
.esci-mx-pasos { display: flex; flex-direction: column; gap: 10px; }
.esci-mx-pasos-int { margin: 0 0 4px; color: var(--ink-2); font-size: var(--fs-ui-sm); line-height: 1.5; }
.esci-mx-paso { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.esci-mx-paso-tit { flex: 0 0 auto; min-width: 190px; font: 500 var(--fs-ui-sm)/1.4 var(--mono); color: var(--ink-2); }
.esci-mx-paso-mat { flex: 1 1 auto; overflow-x: auto; font-size: var(--fs-math); }
.esci-mx-row { display: flex; align-items: center; gap: 4px; }
.esci-mx-grid { display: grid; gap: 4px; padding: 6px 4px; }
.esci-mx-cell { width: 52px; text-align: center; }
.esci-mx-cell.esci-mx-bad { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.esci-mx-bracket { align-self: stretch; width: 8px; border: 2px solid var(--ink-2); flex: 0 0 auto; }
.esci-mx-bracket-l { border-right: none; border-radius: 4px 0 0 4px; }
.esci-mx-bracket-r { border-left: none; border-radius: 0 4px 4px 0; }
.esci-mx-eq { margin: 0 6px; color: var(--ink-3); font-family: var(--mono); font-size: var(--fs-math); }
.esci-mx-result { padding: 6px 12px; border-radius: var(--r-sm); background: var(--result-bg); border: 1px solid var(--result-line); color: var(--result); font-size: var(--fs-math); max-width: 360px; overflow: auto; }
.esci-mx-result[hidden] { display: none; }
.esci-mx-pill { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.esci-mx-pill[hidden] { display: none; }
.esci-mx-pill-item { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); background: var(--result-bg); border: 1px solid var(--result-line); color: var(--result); font-size: var(--fs-ui); }
.esci-mx-pill-lab { color: var(--ink-3); }
.esci-mx-solo-grid .esci-mx-eq, .esci-mx-solo-grid .esci-mx-result { display: none; }
.esci-mx-solo-result .esci-mx-grid, .esci-mx-solo-result .esci-mx-bracket, .esci-mx-solo-result .esci-mx-eq { display: none; }

/* ── TABLA ───────────────────────────────────────────────────────────── */
.esci-table { min-width: 200px; min-height: 120px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-md); box-shadow: var(--shadow-1); box-sizing: border-box; }
.esci-table > .esci-body { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.esci-tb-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 8px; border-bottom: 1px solid var(--line-soft); background: var(--chassis); border-radius: var(--r-md) var(--r-md) 0 0; flex: 0 0 auto; }
.esci-tb-head[hidden] { display: none; }
.esci-tb-sep { width: 1px; align-self: stretch; margin: 2px 4px; background: var(--line); }
.esci-tb-cerrar:hover { color: var(--bad); border-color: var(--bad); }
/* pestaña para volver a abrir el editor cerrado */
.esci-tb-reabrir {
  display: inline-flex; align-items: center; gap: 6px; margin: 4px 0 2px; padding: 3px 10px;
  border: 1px dashed var(--line); border-radius: var(--r-pill); background: transparent;
  color: var(--ink-3); font: 500 var(--fs-label)/1.7 var(--sans); cursor: pointer;
}
.esci-tb-reabrir:hover { border-color: var(--accent); color: var(--accent); border-style: solid; }
.esci-tb-reabrir[hidden] { display: none; }
.esci-tb-fld { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-label); color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.esci-tb-fld .esci-tb-inp { text-transform: none; letter-spacing: 0; }
.esci-tb-name { font-weight: 600; color: var(--define); }
.esci-tb-var { text-align: center; }
.esci-tb-tools { display: flex; gap: 3px; margin-left: auto; }
.esci-tb-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.esci-tb-table { border-collapse: separate; border-spacing: 0; width: 100%; font-family: var(--mono); font-size: var(--fs-ui); }
.esci-tb-table th { position: sticky; z-index: 2; background: var(--chassis-2); text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--line); font-weight: 500; }
.esci-tb-heads th { top: 0; }
.esci-tb-exprs th { top: 42px; border-bottom: 1px solid var(--line-strong); }
.esci-tb-th { display: flex; align-items: center; gap: 4px; }
.esci-tb-colhead { width: 72px; font-weight: 600; color: var(--ink); }
.esci-tb-colexpr { width: 120px; flex: 1 1 auto; }
.esci-tb-unit { color: var(--ink-3); font-size: var(--fs-ui-sm); font-family: var(--mono); }
.esci-tb-exp { color: var(--define); }
.esci-tb-delcol { min-width: 30px; min-height: 30px; padding: 0; margin-left: auto; color: var(--ink-4); border-color: transparent; background: transparent; }
.esci-tb-delcol:hover { color: var(--bad); }
.esci-tb-table td { padding: 4px 10px; border-bottom: 1px solid var(--line-soft); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.esci-tb-table tbody tr:nth-child(even) td { background: var(--chassis); }
.esci-tb-table td.esci-tb-bad { color: var(--bad); cursor: help; text-align: center; }
.esci-tb-foot { padding: 3px 10px; font-size: var(--fs-label); color: var(--ink-4); border-top: 1px solid var(--line-soft); flex: 0 0 auto; }
.esci-tb-foot:empty { display: none; }
.esci-tb-error { margin: 0 8px 8px; }

/* ── volumen del sólido de revolución ──────────────────────────────────────
   Debajo de la gráfica 3D: dibujar el sólido sin decir cuánto mide deja el
   ejercicio a medias, porque lo que se pide en clase es el volumen. Se enseña
   con la fórmula usada, para que se vea de dónde sale el número. */
.esci-p3-volumen {
  margin-top: 8px; padding: 8px 12px;
  border-left: 3px solid var(--result-line, var(--accent));
  background: var(--result-bg, var(--accent-soft)); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--result, var(--ink-2)); font: 500 var(--fs-ui-sm)/1.65 var(--mono);
  overflow-x: auto;
}
.esci-p3-volumen[hidden] { display: none; }

/* ── PANEL DE CONTROLES ────────────────────────────────────────────────────
   Una región con varios mandos, cada uno definiendo su nombre en la hoja.
   Los mandos van en rejilla para que quepan dos o tres por fila cuando el
   panel es ancho, y en una sola columna cuando es estrecho.
   Debajo, el EDITOR: una tarjeta por mando (cabecera con resumen y botones
   de subir, bajar, duplicar y quitar; cuerpo con los campos rotulados), la
   parrilla de fichas para añadir y el pie con las columnas. */
.esci-controles {
  min-width: 240px; background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r-md); box-shadow: var(--shadow-1); box-sizing: border-box;
  font-family: var(--sans); font-size: var(--fs-ui); color: var(--ink);
}
.esci-controles [hidden] { display: none !important; }
/* botones del panel (el estilo común de las regiones de datos) */
.esci-controles .esci-btn {
  min-width: 30px; min-height: 28px; padding: 0 7px; border-radius: var(--r-sm);
  border: 1px solid var(--key-line); background: var(--key); color: var(--ink-2);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 500 var(--fs-ui-sm) var(--sans); transition: background .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease);
}
.esci-controles .esci-btn:hover:not(:disabled) { background: var(--key-hover); border-color: var(--key-hover-line); color: var(--accent); }
.esci-controles .esci-btn:disabled { opacity: .38; cursor: default; }
.esci-controles .esci-btn.esci-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.esci-controles .esci-btn-text { padding: 0 10px; }
.esci-controles input:focus-visible, .esci-controles select:focus-visible, .esci-controles button:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 1px; }

.esci-ct-cab {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px;
  border-bottom: 1px solid var(--line-soft); background: var(--chassis);
  border-radius: var(--r-md) var(--r-md) 0 0; color: var(--ink-3);
}
.esci-ct-tit {
  flex: 0 1 auto; min-width: 0; width: 150px; min-height: 26px; padding: 0 6px;
  border: 1px solid transparent; border-radius: var(--r-sm); background: transparent;
  color: var(--ink); font: 600 var(--fs-ui)/1 var(--sans);
}
.esci-ct-tit:hover, .esci-ct-tit:focus { border-color: var(--line); background: var(--surface); }
.esci-ct-flex { flex: 1 1 auto; }
.esci-ct-cuenta { color: var(--ink-4); font: 500 var(--fs-label) var(--sans); white-space: nowrap; }
.esci-ct-edit span { font-weight: 600; }
.esci-ct-lista { display: grid; gap: 6px 14px; padding: 9px 10px; }
.esci-ct-vacio { color: var(--ink-4); font-size: var(--fs-ui-sm); font-style: italic; display: flex; gap: 6px; align-items: center; }
.esci-ct-item { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 30px; border-radius: var(--r-sm); padding: 0 4px; margin: 0 -4px; }
/* en modo edición cada fila es también un atajo a su tarjeta */
.esci-controles.is-editando .esci-ct-item { cursor: pointer; }
.esci-controles.is-editando .esci-ct-item:hover { background: var(--accent-soft); }
.esci-ct-lab { flex: 0 0 auto; max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-size: var(--fs-ui-sm); }
.esci-ct-rng { flex: 1 1 auto; min-width: 60px; accent-color: var(--accent); height: 26px; }
.esci-ct-eco {
  flex: 0 0 auto; min-width: 62px; text-align: right;
  font: 500 var(--fs-ui-sm)/1 var(--mono); color: var(--result, var(--ink));
}
.esci-ct-num { width: 84px; min-height: 30px; padding: 0 6px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: 500 var(--fs-ui-sm) var(--mono); }
.esci-ct-uni { color: var(--ink-3); font: 500 var(--fs-label) var(--mono); }
/* la unidad a la vista es un botón: un clic y se cambia, sin entrar a editar */
.esci-ct-uni-btn { border: 1px solid transparent; border-radius: var(--r-xs); background: transparent; padding: 2px 5px; min-height: 24px; cursor: pointer; color: var(--ink-3); }
.esci-ct-uni-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.esci-ct-chk { width: 18px; height: 18px; accent-color: var(--accent); flex: 0 0 auto; }
.esci-ct-sel { min-height: 30px; padding: 0 6px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: 500 var(--fs-ui-sm) var(--sans); max-width: 100%; }
/* interruptor: un botón con su pomo, no una casilla disfrazada */
.esci-ct-sw {
  flex: 0 0 auto; width: 40px; height: 22px; padding: 2px; border-radius: 11px;
  border: 1px solid var(--line-strong); background: var(--sunk); cursor: pointer;
  display: inline-flex; align-items: center; transition: background .14s var(--ease), border-color .14s var(--ease);
}
.esci-ct-swk { width: 16px; height: 16px; border-radius: 50%; background: var(--ink-4); transition: transform .14s var(--ease), background .14s var(--ease); }
.esci-ct-sw.is-on { background: var(--accent-soft); border-color: var(--accent); }
.esci-ct-sw.is-on .esci-ct-swk { transform: translateX(18px); background: var(--accent); }
.esci-ct-boton { width: 100%; justify-content: center; }
.esci-controles .esci-btn.esci-ct-boton { min-height: 32px; font-weight: 600; }
/* el nombre que define el mando, a la derecha y discreto */
.esci-ct-nom {
  flex: 0 0 auto; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--define-bg, var(--sunk)); color: var(--define, var(--ink-3));
  font: 600 var(--fs-label)/1.7 var(--mono);
}
.esci-ct-nom.is-vacio { background: var(--bad-soft); color: var(--bad); font-family: var(--sans); font-weight: 500; }
.esci-ct-error { margin: 0 10px 8px; padding: 6px 10px; border-radius: var(--r-sm); background: var(--bad-soft); color: var(--bad); font-size: var(--fs-ui-sm); display: flex; gap: 8px; align-items: flex-start; }

/* ── el editor ── */
.esci-ct-editor { padding: 8px 10px 10px; border-top: 1px dashed var(--line); background: var(--sunk); border-radius: 0 0 var(--r-md) var(--r-md); }
.esci-ct-ed-cab { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; }
.esci-ct-ed-tit { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font: 600 var(--fs-ui-sm) var(--sans); }
.esci-ct-ed-tit small { color: var(--ink-4); font-weight: 500; }
.esci-controles .esci-btn.esci-ct-addbtn { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.esci-controles .esci-btn.esci-ct-addbtn:hover:not(:disabled) { background: var(--accent-hi); border-color: var(--accent-hi); color: var(--on-accent); }
.esci-controles .esci-btn.esci-ct-addbtn.esci-on { background: var(--surface); color: var(--accent); }
/* fichas para añadir: icono grande, nombre y qué hace */
.esci-ct-fichas { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-bottom: 10px; }
.esci-controles .esci-btn.esci-ct-ficha {
  justify-content: flex-start; align-items: flex-start; gap: 8px; padding: 8px; min-height: 0; text-align: left; white-space: normal;
  border-color: var(--line); background: var(--surface);
}
.esci-controles .esci-btn.esci-ct-ficha:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.esci-ct-ficha-ic { flex: 0 0 auto; width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 14px; }
.esci-ct-ficha-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.esci-ct-ficha-tx b { font-weight: 600; font-size: var(--fs-ui-sm); color: var(--ink); }
.esci-ct-ficha-tx small { font-size: var(--fs-label); line-height: 1.35; color: var(--ink-3); }
/* tarjetas */
.esci-ct-cards { display: flex; flex-direction: column; gap: 5px; }
.esci-ct-card { border: 1px solid var(--line-soft); border-radius: var(--r-sm); background: var(--surface); overflow: hidden; }
.esci-ct-card.is-open { border-color: var(--accent-ring); box-shadow: 0 0 0 1px var(--accent-ring); }
.esci-ct-card.is-bad { border-color: var(--bad); }
.esci-ct-card-cab { display: flex; align-items: center; gap: 4px; padding: 3px 4px 3px 0; }
.esci-ct-card-abre {
  flex: 1 1 auto; min-width: 0; min-height: 30px; display: flex; align-items: center; gap: 7px; padding: 0 6px 0 8px;
  border: 0; background: transparent; color: var(--ink); text-align: left; cursor: pointer; border-radius: var(--r-sm);
}
.esci-ct-card-abre:hover { background: var(--accent-soft); }
.esci-ct-card-ic { flex: 0 0 auto; width: 22px; height: 22px; border-radius: var(--r-xs); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 11px; }
/* el rótulo no se encoge (hasta la mitad); el resumen toma lo que sobre y se recorta */
.esci-ct-card-tit { flex: 0 0 auto; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 var(--fs-ui-sm) var(--sans); }
.esci-ct-card-res { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-4); font: 500 var(--fs-label) var(--mono); }
.esci-ct-card-flecha { flex: 0 0 auto; font-size: 10px; color: var(--ink-4); transition: transform .14s var(--ease); }
.esci-ct-card.is-open .esci-ct-card-flecha { transform: rotate(180deg); }
.esci-ct-card-herr { flex: 0 0 auto; display: inline-flex; gap: 2px; }
.esci-ct-card-herr .esci-btn { min-width: 28px; min-height: 28px; padding: 0 4px; border-color: transparent; background: transparent; }
.esci-ct-card-herr .esci-btn i { font-size: 11px; }
.esci-controles .esci-btn.esci-ct-del:hover:not(:disabled) { color: var(--bad); border-color: var(--bad); background: var(--bad-soft); }
.esci-ct-card-body { padding: 4px 8px 8px; border-top: 1px solid var(--line-soft); background: var(--chassis-2); }
.esci-ct-rej { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px 8px; }
.esci-ct-edf { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.esci-ct-edf.is-medio { grid-column: span 2; }
.esci-ct-edf-lab { color: var(--ink-4); font: 500 var(--fs-label) var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.esci-ct-in { min-height: 28px; width: 100%; padding: 0 6px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: 500 var(--fs-ui-sm) var(--sans); box-sizing: border-box; }
.esci-ct-in.is-mono { font-family: var(--mono); }
.esci-ct-in:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px var(--accent-ring); }
.esci-ct-edf .esci-ct-sel { width: 100%; min-height: 28px; box-sizing: border-box; }
/* el botón de unidad: enseña la actual y abre la ventana */
.esci-ct-ubtn {
  min-height: 28px; width: 100%; padding: 0 6px; display: inline-flex; align-items: center; justify-content: space-between; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); cursor: pointer;
  font: 600 var(--fs-ui-sm) var(--mono); box-sizing: border-box;
}
.esci-ct-ubtn:hover { border-color: var(--accent); background: var(--accent-soft); }
.esci-ct-ubtn i { font-size: 10px; color: var(--ink-4); }
.esci-ct-ubtn.is-sin .esci-ct-ubtn-tx { color: var(--ink-4); font: 500 var(--fs-ui-sm) var(--sans); font-style: italic; }
.esci-ct-ubtn.is-bad { border-color: var(--bad); color: var(--bad); }
.esci-ct-ubtn-tx { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* opciones de una lista */
.esci-ct-ops { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.esci-ct-ops-cab { display: grid; grid-template-columns: 28px 1fr 1.4fr 28px; gap: 4px; align-items: end; }
.esci-ct-ops-cab .esci-ct-edf-lab { grid-column: 1 / -1; }
.esci-ct-ops-col { color: var(--ink-4); font: 500 var(--fs-label) var(--sans); }
.esci-ct-ops-cab .esci-ct-ops-col:first-of-type { grid-column: 2; }
.esci-ct-op { display: grid; grid-template-columns: 28px 1fr 1.4fr 28px; gap: 4px; align-items: center; }
.esci-ct-op.is-inicial .esci-ct-op-ini { color: var(--accent); }
.esci-ct-op-ini { width: 28px; height: 28px; border: 0; background: transparent; color: var(--ink-4); cursor: pointer; border-radius: var(--r-sm); display: grid; place-items: center; }
.esci-ct-op-ini:hover { color: var(--accent); background: var(--accent-soft); }
.esci-controles .esci-btn.esci-ct-op-mas { align-self: flex-start; min-height: 26px; }
/* ayuda y avisos dentro de la tarjeta */
.esci-ct-ayuda { margin-top: 8px; padding: 5px 8px; border-radius: var(--r-sm); background: var(--result-bg); color: var(--result); font: 500 var(--fs-label)/1.45 var(--sans); display: flex; gap: 6px; align-items: flex-start; }
.esci-ct-ayuda i { margin-top: 2px; }
.esci-ct-msg { margin: 4px 8px 6px; padding: 5px 8px; border-radius: var(--r-sm); background: var(--bad-soft); color: var(--bad); font: 500 var(--fs-label)/1.45 var(--sans); display: flex; gap: 6px; align-items: flex-start; }
.esci-ct-card-body .esci-ct-msg { margin: 6px 0 0; }
.esci-ct-msg i { margin-top: 2px; }
/* pie del editor */
.esci-ct-ed-pie { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--line); }
.esci-ct-cols { display: inline-flex; align-items: center; gap: 3px; }
.esci-ct-cols .esci-ct-edf-lab { margin-right: 3px; }
.esci-ct-cols .esci-btn { min-width: 28px; min-height: 26px; padding: 0 5px; }
.esci-ct-pista { color: var(--ink-4); font: 500 var(--fs-label) var(--sans); display: inline-flex; gap: 5px; align-items: center; }
@media (pointer: coarse) {
  .esci-ct-item { min-height: 40px; }
  .esci-ct-sw { width: 52px; height: 28px; border-radius: 14px; }
  .esci-ct-swk { width: 22px; height: 22px; }
  .esci-ct-sw.is-on .esci-ct-swk { transform: translateX(24px); }
  .esci-controles .esci-btn, .esci-ct-in, .esci-ct-ubtn, .esci-ct-edf .esci-ct-sel, .esci-ct-card-abre { min-height: 36px; }
  .esci-ct-card-herr .esci-btn { min-width: 36px; min-height: 36px; }
  .esci-ct-op-ini, .esci-ct-uni-btn { min-width: 36px; min-height: 36px; }
}

/* ── ayuda por trazo y asistente de gráficas ─────────────────────────── */
.esci-plot-ayuda { flex: 1 1 100%; padding: 2px 4px 0 40px; font-size: var(--fs-label); color: var(--ink-3); line-height: 1.4; display: flex; gap: 6px; align-items: flex-start; }
.esci-plot-ayuda i { color: var(--accent); margin-top: 2px; }
.esci-plot .esci-btn.esci-plot-asisbtn { color: var(--accent); }
.esci-plot-asis-intro { margin: 0 0 10px; color: var(--ink-2); }
.esci-plot-asis-rej { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.esci-plot-asis-grp { grid-column: 1 / -1; font: 600 var(--fs-label) var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4); padding-top: 6px; }
.esci-plot-asis-ficha {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink); cursor: pointer; transition: border-color .12s var(--ease), background .12s var(--ease);
}
.esci-plot-asis-ficha:hover { border-color: var(--accent); background: var(--accent-soft); }
.esci-plot-asis-ficha:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 1px; }
.esci-plot-asis-ic { flex: 0 0 auto; width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 15px; }
.esci-plot-asis-tx { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.esci-plot-asis-tx b { font-size: var(--fs-ui); }
.esci-plot-asis-tx code { font: 500 var(--fs-ui-sm) var(--mono); color: var(--result); background: var(--result-bg); padding: 1px 6px; border-radius: var(--r-xs); align-self: flex-start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.esci-plot-asis-tx small { font-size: var(--fs-label); color: var(--ink-3); line-height: 1.4; }

/* ── distribuciones: menú y parámetros con nombre ────────────────────────── */
.esci-plot-dist { max-width: 168px; }
.esci-plot-parwrap { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.esci-plot-parlab { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-label); color: var(--ink-3); }
.esci-plot-parlab[hidden] { display: none; }
.esci-plot-parnom { font-family: var(--serif); font-style: italic; font-size: 12px; color: var(--ink-2); }
.esci-plot-par { width: 60px; flex: none; min-width: 0; }
.esci-plot-momentos { font-family: var(--mono); color: var(--ink-2); }
