/* ═══════════════════════════════════════════════════════════════════
   METIS — Hoja única del sistema de diseño (v0.4.0).
   Reglas que esto fija (ver METIS_DISENO):
     · Ningún valor fuera de las variables de :root.
     · Cada componente tiene una sola implementación.
     · Toda variante de control declara sus estados: normal, cursor
       encima, foco visible, pulsado, deshabilitado y ocupado.
     · Todo componente con display propio respeta [hidden].
     · Nada inline en el HTML (la CSP lo prohíbe): todo vive aquí.
   ═══════════════════════════════════════════════════════════════════ */

/* ── 1. FUENTES PROPIAS ───────────────────────────────────────────
   Archivos en assets/libs/fuentes/. Si aún no se han subido, las
   familias de respaldo mantienen la plataforma legible. */
@font-face {
    font-family: 'Bricolage Grotesque';
    src: url('../libs/fuentes/bricolage-600.woff') format('woff');
    font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Bricolage Grotesque';
    src: url('../libs/fuentes/bricolage-700.woff') format('woff');
    font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Public Sans';
    src: url('../libs/fuentes/publicsans-400.woff') format('woff');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Public Sans';
    src: url('../libs/fuentes/publicsans-600.woff') format('woff');
    font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Public Sans';
    src: url('../libs/fuentes/publicsans-700.woff') format('woff');
    font-weight: 700; font-style: normal; font-display: swap;
}

/* ── 2. FUNDAMENTOS ─────────────────────────────────────────────── */
:root {
    /* Marca */
    --marino: #022554;
    --petroleo-osc: #06325a;
    --petroleo: #05416c;
    --azul: #01a2bb;
    --turquesa: #13dcda;
    --agua: #28d7c8;
    --cian: #75e2ea;
    --oro: #e2a33a;
    --oro-claro: #f3c969;

    /* Papeles del panel claro */
    --fondo: #f4f7fa;
    --superficie: #ffffff;
    --superficie2: #eff4f9;
    --superficie3: #e3ecf4;
    --borde: #dce5ee;
    --borde2: #bccbda;
    --texto: #0c1c30;
    --texto2: #41566e;
    --tenue: #6e829a;

    /* Estados: tinta, fondo, borde */
    --ok: #0f8a6a;        --ok-fondo: #e4f4ef;        --ok-borde: #bce3d7;
    --atencion: #a2680b;  --atencion-fondo: #fbf0dc;  --atencion-borde: #edd5a7;
    --error: #c0392f;     --error-fondo: #fbebe9;     --error-borde: #f0c4bf;
    --info: #0a6e9b;      --info-fondo: #e4f1f8;      --info-borde: #b9d8ea;
    --ok-solido: var(--ok); --error-solido: var(--error);   /* rellenos con texto blanco encima */

    /* Papeles que cambian con el tema (v0.4.7.1, acuerdos 133A a 136A). La marca no cambia; cambia su papel. */
    --tinta-1: var(--marino);          /* h1, nombres activos */
    --tinta-2: var(--petroleo-osc);    /* h2, h3, pestañas activas */
    --tinta-3: var(--petroleo);        /* enlaces, códigos, iconos de trazo */
    --acento: var(--azul);             /* foco, bordes activos, interruptores */
    --relleno: var(--petroleo-osc); --relleno-hover: var(--marino); --sobre-relleno: #fff;
    --sobre-oro: #3a2704;
    --cabecera-fondo: rgba(255, 255, 255, .88);
    --toast-fondo: var(--marino); --toast-texto: #eaf2fa;
    --velo: rgba(2, 22, 48, .5);
    --wordmark: var(--marino);

    /* Barra lateral y barra de iconos: oscuras en los dos temas (DT-10) */
    --lat-texto: #d5e4f2; --lat-enlace: #bfd4e8; --lat-tenue: #7fa3c4; --lat-version: #5d7f9f; --lat-blanco: #fff;
    --lat-hover: rgba(255, 255, 255, .07); --lat-activo: rgba(19, 220, 218, .2); --lat-activo2: rgba(19, 220, 218, .05);
    --lat-foco: rgba(19, 220, 218, .45); --lat-base: #021b3e; --lat-color: var(--tinta-1);
    --lat-velo1: rgba(2, 37, 84, .72); --lat-velo2: rgba(2, 37, 84, .94); --lat-transp: rgba(2, 37, 84, 0);
    --lat-brillo: rgba(19, 220, 218, .26); --lat-oro: rgba(226, 163, 58, .2);

    /* Mapa de calor de Salud de modelos */
    --calor-0: #d7f3e8; --calor-1: #fff1c9; --calor-2: #ffd9a0; --calor-2-tinta: #7a4600;
    --calor-3: #ffb3a0; --calor-3-tinta: #7d1f13; --calor-4: #e0675f; --calor-4-tinta: #fff;

    /* Impresos: siempre claros, en cualquier tema */
    --imp-fondo: #fff; --imp-corte: #8aa0b2; --imp-caja: #eaf8fa; --imp-caja-borde: #cdeff3;

    /* Portada de acceso */
    --portada-fondo: #eaf7fa; --portada-brillo: rgba(19, 220, 218, .14); --portada-transp: rgba(244, 247, 250, 0);

    /* Letra: dos familias, papeles distintos */
    --f-titulo: 'Bricolage Grotesque', 'Trebuchet MS', system-ui, sans-serif;
    --f-texto: 'Public Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --f-mono: ui-monospace, 'SFMono-Regular', Consolas, Menlo, monospace;

    /* Escala tipográfica: SEIS tamaños, ninguno más */
    --t-xs: .75rem;
    --t-sm: .8125rem;
    --t-md: .9375rem;
    --t-lg: 1.0625rem;
    --t-xl: 1.375rem;
    --t-2xl: 1.875rem;
    /* Solo pantallas de acceso (v0.4.7.1): el wordmark y el lema de portada. No se usan en el panel. */
    --t-marca: 2rem;
    --t-portada: clamp(2.25rem, 3.6vw, 3.75rem);

    /* Espaciado: escala de 4 */
    --e1: 4px; --e2: 8px; --e3: 12px; --e4: 16px; --e5: 24px; --e6: 32px; --e7: 48px;

    /* Radios, sombras, foco */
    --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pil: 999px;
    --radio: var(--r-md);
    --sombra-1: 0 1px 2px rgba(2, 37, 84, .06), 0 1px 3px rgba(2, 37, 84, .04);
    --sombra-2: 0 2px 4px rgba(2, 37, 84, .06), 0 8px 20px rgba(2, 37, 84, .08);
    --sombra-3: 0 8px 16px rgba(2, 37, 84, .1), 0 24px 56px rgba(2, 37, 84, .16);
    --sombra: var(--sombra-1);
    --anillo: 0 0 0 3px rgba(1, 162, 187, .3);

    /* Movimiento: TRES duraciones, una curva */
    --mov-1: 120ms cubic-bezier(.2, .6, .3, 1);
    --mov-2: 200ms cubic-bezier(.2, .6, .3, 1);
    --mov-3: 320ms cubic-bezier(.2, .6, .3, 1);

    /* Estructura */
    --barra-w: 244px;
    --cabecera-h: 58px;
    --contenido-max: 1240px;

    /* Densidad: lo único que cambia el interruptor */
    --d-campo: 38px;
    --d-fila: 13px 14px;
    --d-caja: var(--e5);
    --d-hueco: var(--e5);
}
html[data-densidad="compacta"] {
    --d-campo: 32px;
    --d-fila: 7px 12px;
    --d-caja: var(--e4);
    --d-hueco: var(--e4);
}

/* Regla general: todo componente con display propio respeta [hidden]. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--f-texto);
    font-size: var(--t-md);
    line-height: 1.55;
    color: var(--texto);
    background: var(--fondo);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--f-titulo); line-height: 1.2; letter-spacing: -.012em; font-weight: 700; }
h1 { font-size: var(--t-2xl); margin: 0 0 var(--e3); color: var(--tinta-1); }
h2 { font-size: var(--t-xl); margin: 0 0 var(--e3); color: var(--tinta-2); }
h3 { font-size: var(--t-lg); margin: 0 0 var(--e2); color: var(--tinta-2); }
p { margin: 0 0 var(--e3); }
a { color: var(--tinta-3); }
img { max-width: 100%; }
code {
    font-family: var(--f-mono); font-size: var(--t-xs);
    background: var(--superficie2); padding: 2px 6px; border-radius: var(--r-sm);
    word-break: break-all;
}
.nota { color: var(--tenue); font-size: var(--t-sm); }

/* Un solo anillo de foco en toda la plataforma */
:focus-visible { outline: none; box-shadow: var(--anillo); border-radius: var(--r-sm); }

/* Barra de desplazamiento propia */
* { scrollbar-width: thin; scrollbar-color: var(--borde2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--borde2); border-radius: var(--r-pil);
    border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--tenue); background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* ── 3. BOTONES ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--e2);
    height: var(--d-campo); padding: 0 var(--e4); margin: 0;
    border: 1px solid transparent; border-radius: var(--r-md);
    font-family: inherit; font-size: var(--t-md); font-weight: 600; line-height: 1;
    text-decoration: none; text-align: center; white-space: nowrap; cursor: pointer;
    background: var(--relleno); color: var(--sobre-relleno);
    transition: background var(--mov-1), border-color var(--mov-1), color var(--mov-1), box-shadow var(--mov-1);
}
.btn:hover { background: var(--relleno-hover); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; }

.btn-sec { background: var(--superficie); color: var(--texto); border-color: var(--borde2); }
.btn-sec:hover { background: var(--superficie2); border-color: var(--tenue); color: var(--tinta-1); }

.btn-peligro { background: var(--superficie); color: var(--error); border-color: var(--error-borde); }
.btn-peligro:hover { background: var(--error-solido); color: #fff; border-color: var(--error-solido); }

/* Oro: una sola acción destacada por pantalla. */
.btn-oro {
    background: linear-gradient(180deg, var(--oro-claro), var(--oro));
    color: var(--sobre-oro); border-color: rgba(0, 0, 0, .08); box-shadow: var(--sombra-1);
}
.btn-oro:hover { filter: brightness(1.05); background: linear-gradient(180deg, var(--oro-claro), var(--oro)); }

.btn-mini { height: 30px; padding: 0 var(--e3); font-size: var(--t-sm); border-radius: var(--r-sm); }
.btn-ic { width: var(--d-campo); padding: 0; }
.btn-mini.btn-ic { width: 30px; }
.btn-ancho { display: flex; width: 100%; margin: 0 0 var(--e2); }

/* Estado ocupado: sin clics y con giro */
.btn.cargando { pointer-events: none; opacity: .75; cursor: progress; }
.btn.cargando::before {
    content: ''; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid currentColor; border-top-color: transparent;
    animation: metis-gira .7s linear infinite;
}
@keyframes metis-gira { to { transform: rotate(360deg); } }

.enlace {
    background: none; border: 0; padding: var(--e1) 0; cursor: pointer;
    font: inherit; color: var(--tinta-3); text-decoration: underline;
}
.enlace:hover { color: var(--tinta-1); }

.btn + .btn, .btn + .enlace, .enlace + .btn { margin-left: var(--e2); }
.acciones { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2); }
.acciones .btn + .btn, .fila-archivo .btn + .btn, .dialogo-acciones .btn + .btn,
.card-pie .btn + .btn, .cabecera .btn + .btn { margin-left: 0; }
.acciones-mini { min-width: 230px; }

/* ── 4. CAMPOS ──────────────────────────────────────────────────── */
.campo { display: block; margin-bottom: var(--e4); }
.campo > span {
    display: block; font-size: var(--t-sm); font-weight: 600;
    color: var(--texto2); margin-bottom: 5px;
}
.campo .ayuda { display: block; font-size: var(--t-xs); color: var(--tenue); margin-top: 5px; font-weight: 400; }
.campo .err { display: block; font-size: var(--t-xs); color: var(--error); margin-top: 5px; font-weight: 400; }
.campo input, .campo textarea, .campo select {
    width: 100%; font: inherit; font-size: var(--t-md); color: var(--texto);
    height: var(--d-campo); padding: 0 var(--e3);
    background: var(--superficie); border: 1px solid var(--borde2); border-radius: var(--r-md);
    transition: border-color var(--mov-1), box-shadow var(--mov-1);
}
.campo textarea {
    height: auto; min-height: 92px; padding: var(--e3); resize: vertical;
    font-family: var(--f-mono); font-size: var(--t-sm); line-height: 1.55;
}
.campo input::placeholder, .campo textarea::placeholder { color: var(--tenue); }
.campo input:hover, .campo textarea:hover, .campo select:hover { border-color: var(--tenue); }
.campo input:focus, .campo textarea:focus, .campo select:focus {
    outline: none; border-color: var(--acento); box-shadow: var(--anillo);
}
.campo input[disabled], .campo textarea[disabled], .campo select[disabled] {
    background: var(--superficie2); color: var(--tenue); cursor: not-allowed;
}
.campo input[readonly], .campo textarea[readonly] { background: var(--superficie2); }
.campo.malo input, .campo.malo textarea, .campo.malo select { border-color: var(--error); }
.campo select {
    appearance: none; cursor: pointer; padding-right: var(--e6);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236e829a' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right var(--e3) center;
}
.campo-corto input, .campo-corto select { max-width: 190px; }
.campo-medio input, .campo-medio select { max-width: 380px; }
.fila-campos {
    display: grid; gap: var(--e4);
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}
.fila-campos .campo { min-width: 0; }

/* Texto corrido (historia, mensajes): letra de texto, no la monoespaciada de las listas. */
.campo-texto textarea { font-family: var(--f-texto); font-size: var(--t-md); }
/* Acciones que cuelgan de un campo (ayuda de Gemini, agregar elemento). */
.campo-acciones { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2); margin: calc(var(--e2) * -1) 0 var(--e4); }
/* Lista editable: una fila por elemento, con identificador estable detrás. */
.lista-edit { margin-bottom: var(--e3); }
.fila-lista.campo { display: flex; align-items: center; gap: var(--e2); margin-bottom: var(--e2); }
.fila-lista input { flex: 1; min-width: 0; }
.fila-lista .btn { flex: none; }

.casilla { display: inline-flex; align-items: center; gap: var(--e2); margin: 0 0 var(--e3); cursor: pointer; }
.casilla input { width: 18px; height: 18px; accent-color: var(--tinta-2); }

/* Interruptor */
.palanca { display: inline-flex; align-items: center; gap: var(--e3); cursor: pointer; user-select: none; font-size: var(--t-sm); }
.palanca input { position: absolute; opacity: 0; width: 0; height: 0; }
.palanca i {
    width: 40px; height: 23px; border-radius: var(--r-pil); background: var(--borde2);
    position: relative; flex: none; transition: background var(--mov-2);
}
.palanca i::after {
    content: ''; position: absolute; width: 17px; height: 17px; border-radius: 50%;
    background: #fff; top: 3px; left: 3px; box-shadow: var(--sombra-1);
    transition: transform var(--mov-2);
}
.palanca input:checked + i { background: var(--acento); }
.palanca input:checked + i::after { transform: translateX(17px); }
.palanca input:focus-visible + i { box-shadow: var(--anillo); }

.fila-archivo { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2) var(--e4); margin-bottom: var(--e2); }
.fila-archivo .btn { cursor: pointer; }
.fila-archivo:focus-within .btn { box-shadow: var(--anillo); }
.oculto, .oculto-archivo {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.separador { border: 0; border-top: 1px solid var(--borde); margin: var(--e5) 0; }

/* ── 5. MENSAJES ────────────────────────────────────────────────── */
.msg {
    padding: var(--e2) var(--e3); border-radius: var(--r-md);
    background: var(--superficie2); font-size: var(--t-sm);
}
.msg:empty { display: none; }
.msg-ok { background: var(--ok-fondo); color: var(--ok); }
.msg-error { background: var(--error-fondo); color: var(--error); }

.aviso {
    padding: var(--e3) var(--e4); border-radius: var(--r-md);
    margin-bottom: var(--e4); font-size: var(--t-sm); border: 1px solid var(--borde);
    background: var(--superficie2); color: var(--texto2);
}
.aviso-atencion { background: var(--atencion-fondo); color: var(--atencion); border-color: var(--atencion-borde); }
.aviso-ok { background: var(--ok-fondo); color: var(--ok); border-color: var(--ok-borde); margin-top: var(--e4); }
.aviso-info { background: var(--info-fondo); color: var(--info); border-color: var(--info-borde); }
.aviso-error { background: var(--error-fondo); color: var(--error); border-color: var(--error-borde); }
.aviso p:last-child { margin-bottom: 0; }
.aviso a { color: inherit; }

/* ── 6. ETIQUETAS DE ESTADO: vocabulario cerrado ────────────────── */
.chip {
    display: inline-flex; align-items: center; gap: 5px; vertical-align: middle;
    padding: 2px 10px; border-radius: var(--r-pil);
    font-size: var(--t-xs); font-weight: 600; white-space: nowrap;
    background: var(--superficie2); color: var(--texto2); border: 1px solid var(--borde);
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip-ok { background: var(--ok-fondo); color: var(--ok); border-color: var(--ok-borde); }
.chip-pend { background: var(--atencion-fondo); color: var(--atencion); border-color: var(--atencion-borde); }
.chip-err { background: var(--error-fondo); color: var(--error); border-color: var(--error-borde); }
.chip-inf { background: var(--info-fondo); color: var(--info); border-color: var(--info-borde); }
.chip-liso::before { display: none; }

/* ── 7. TARJETA: una sola anatomía ──────────────────────────────── */
.card {
    background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-lg);
    padding: var(--d-caja); margin-bottom: var(--d-hueco); box-shadow: var(--sombra-1);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-cab {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--e4); flex-wrap: wrap; margin-bottom: var(--e4);
}
.card-cab h2, .card-cab h3 { margin: 0; }
.card-cab .nota { margin-top: 2px; }
.card-pie {
    display: flex; justify-content: flex-end; gap: var(--e2); flex-wrap: wrap;
    margin: var(--e4) calc(var(--d-caja) * -1) calc(var(--d-caja) * -1);
    padding: var(--e4) var(--d-caja);
    border-top: 1px solid var(--borde); background: var(--superficie2);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.rejilla {
    display: grid; gap: var(--d-hueco);
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
}
.rejilla > .card { margin-bottom: 0; }

/* Tarjeta con lomo de color (D-43): la identidad de un escape room en la lista. */
.card-lomo { position: relative; padding-left: calc(var(--d-caja) + var(--e2)); }
.card-lomo::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: var(--e2);
    border-radius: var(--r-lg) 0 0 var(--r-lg);
    background: linear-gradient(180deg, var(--marino), var(--azul));
}
.card-lomo.lomo-2::before { background: linear-gradient(180deg, var(--petroleo), var(--turquesa)); }
.card-lomo.lomo-3::before { background: linear-gradient(180deg, var(--azul), var(--agua)); }
.card-lomo.lomo-off::before { background: var(--borde2); }
.card-lomo .card-pie { border-radius: 0 0 var(--r-lg) 0; }
.card-lomo h3 { min-height: 2.4em; overflow-wrap: anywhere; }
.card-lomo .desc {
    color: var(--texto2); font-size: var(--t-sm); min-height: 3.2em; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ── 8. PESTAÑAS ────────────────────────────────────────────────── */
.pestanas {
    display: flex; gap: var(--e1); overflow-x: auto;
    border-bottom: 1px solid var(--borde); margin-bottom: var(--e5);
}
.pestanas button {
    border: 0; background: transparent; cursor: pointer; white-space: nowrap;
    padding: var(--e3) var(--e3) 10px; margin-bottom: -1px;
    font: inherit; font-size: var(--t-md); font-weight: 600; color: var(--tenue);
    border-bottom: 2px solid transparent;
    display: flex; align-items: center; gap: var(--e2);
    transition: color var(--mov-1), border-color var(--mov-1);
}
.pestanas button:hover { color: var(--texto); }
.pestanas button[aria-selected="true"] { color: var(--tinta-2); border-bottom-color: var(--acento); }
.pestanas .cuenta { background: var(--superficie3); border-radius: var(--r-pil); padding: 0 7px; font-size: var(--t-xs); }

/* ── 9. FILTROS ─────────────────────────────────────────────────── */
.barra-filtros {
    display: flex; align-items: center; gap: var(--e3); flex-wrap: wrap;
    margin-bottom: var(--e3);
}
.barra-filtros .busca { flex: 1; min-width: 200px; }
.barra-filtros .campo { margin-bottom: 0; }
.busca { position: relative; }
.busca input { padding-left: 38px; }
.busca svg {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    width: 17px; height: 17px; fill: none; stroke: var(--tenue); stroke-width: 2; pointer-events: none;
}
.filtros-puestos { display: flex; align-items: center; gap: var(--e2); flex-wrap: wrap; margin-bottom: var(--e3); }
.filtros-puestos .rotulo { font-size: var(--t-xs); color: var(--tenue); }
.filtro-puesto {
    display: inline-flex; align-items: center; gap: var(--e1);
    padding: 3px 4px 3px 10px; border-radius: var(--r-pil);
    background: var(--superficie); border: 1px solid var(--borde2);
    font-size: var(--t-xs); font-weight: 600;
}
.filtro-puesto button {
    border: 0; background: transparent; cursor: pointer; font: inherit;
    width: 18px; height: 18px; border-radius: 50%; color: var(--tenue); line-height: 1;
}
.filtro-puesto button:hover { background: var(--superficie3); color: var(--texto); }

/* ── 10. MENÚ DESPLEGABLE ───────────────────────────────────────── */
.menu { position: relative; display: inline-block; }
.menu-panel {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 216px;
    background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-md);
    box-shadow: var(--sombra-3); padding: var(--e1); display: none;
}
.menu-panel[data-arriba] { top: auto; bottom: calc(100% + 6px); }
.menu.abierto .menu-panel { display: block; animation: metis-menu var(--mov-1) both; }
@keyframes metis-menu { from { opacity: 0; transform: translateY(-4px); } }
.menu-panel button {
    display: flex; align-items: center; gap: var(--e3); width: 100%;
    padding: 8px var(--e3); border: 0; background: transparent; cursor: pointer;
    border-radius: var(--r-sm); font: inherit; font-size: var(--t-sm);
    text-align: left; color: var(--texto);
}
.menu-panel button:hover, .menu-panel button:focus-visible { background: var(--superficie2); }
.menu-panel hr { border: 0; border-top: 1px solid var(--borde); margin: var(--e1) 0; }
.menu-panel .peligro { color: var(--error); }
.menu-panel svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ── 11. TABLAS ─────────────────────────────────────────────────── */
.tabla-wrap { position: relative; overflow-x: auto; }
.tabla-alta { max-height: 460px; overflow-y: auto; }
.tabla-alta .tabla th { position: sticky; top: 0; z-index: 10; }
.tabla { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.tabla th {
    text-align: left;
    background: var(--superficie2); color: var(--texto2);
    font-weight: 600; font-size: var(--t-xs); padding: 10px 14px;
    border-bottom: 1px solid var(--borde); white-space: nowrap;
}
.tabla td {
    padding: var(--d-fila); border-bottom: 1px solid var(--borde);
    vertical-align: middle; min-width: 0; overflow-wrap: anywhere;
}
.tabla tbody tr:hover td { background: var(--superficie2); }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla .acciones { white-space: nowrap; justify-content: flex-end; }
.tabla .acciones-mini { white-space: normal; }
.col-fija { width: 1%; white-space: nowrap; }
.codigo { font-weight: 600; letter-spacing: .04em; white-space: nowrap; font-family: var(--f-mono); }
.fila-baja td { color: var(--tenue); }
.fila-baja .codigo { text-decoration: line-through; }
.pasos li { margin-bottom: var(--e2); }

/* Esqueleto de carga: nunca la palabra «Cargando» suelta */
.esq {
    background: linear-gradient(90deg, var(--superficie2) 25%, var(--superficie3) 37%, var(--superficie2) 63%);
    background-size: 400% 100%; animation: metis-esq 1.3s ease infinite;
    border-radius: var(--r-sm); height: 12px;
}
@keyframes metis-esq { from { background-position: 100% 0; } to { background-position: 0 0; } }
.esq-l { width: 70%; margin-bottom: var(--e3); }
.esq-m { width: 45%; margin-bottom: var(--e3); }
.esq-c { width: 25%; }

/* Pantalla vacía: dice qué falta y ofrece crearlo */
.vacio { text-align: center; padding: var(--e7) var(--e5); }
.vacio svg { width: 54px; height: 54px; fill: none; stroke: var(--borde2); stroke-width: 1.4; margin: 0 auto var(--e4); display: block; }
.vacio h3 { margin-bottom: var(--e2); }
.vacio p { color: var(--tenue); max-width: 44ch; margin: 0 auto var(--e5); font-size: var(--t-sm); }

/* ── 12. ARMAZÓN DEL PANEL ──────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--barra-w) 1fr; min-height: 100vh; }
.lateral {
    position: sticky; top: 0; align-self: start; height: 100vh;
    display: flex; flex-direction: column; overflow: hidden;
    color: var(--lat-texto);
    background:
        linear-gradient(180deg, var(--lat-velo1) 0%, var(--lat-velo2) 48%, var(--lat-base) 100%),
        radial-gradient(120% 70% at 20% 8%, var(--lat-brillo) 0%, var(--lat-transp) 58%),
        radial-gradient(90% 55% at 85% 100%, var(--lat-oro) 0%, var(--lat-transp) 60%),
        var(--lat-color);
}
.marca {
    display: flex; align-items: center; gap: var(--e3); text-decoration: none;
    padding: var(--e5) var(--e4) var(--e5) var(--e5);
}
.marca img { flex: none; }
.marca-txt { font-family: var(--f-titulo); line-height: 1.05; }
.marca-txt b { display: block; color: var(--lat-blanco); font-size: 1.2rem; letter-spacing: .08em; font-weight: 700; }
.marca-txt span { display: block; font-family: var(--f-texto); font-size: var(--t-xs); color: var(--cian); letter-spacing: 0; }
.lateral nav { display: flex; flex-direction: column; gap: 2px; padding: 0 var(--e3); overflow-y: auto; }
.nav-grupo { font-size: var(--t-xs); color: var(--lat-tenue); padding: var(--e4) var(--e3) var(--e2); }
.lateral nav a {
    display: flex; align-items: center; gap: var(--e3);
    color: var(--lat-enlace); text-decoration: none; padding: 9px var(--e3);
    border-radius: var(--r-md); font-size: var(--t-md); font-weight: 500;
    transition: background var(--mov-1), color var(--mov-1);
}
.lateral nav a:hover { background: var(--lat-hover); color: var(--lat-blanco); }
.lateral nav a[aria-current="page"] {
    background: linear-gradient(90deg, var(--lat-activo), var(--lat-activo2));
    color: var(--lat-blanco); box-shadow: inset 2px 0 0 var(--turquesa);
}
.lateral nav svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; }
.lateral :focus-visible, .barra-ic :focus-visible { box-shadow: 0 0 0 3px var(--lat-foco); }
.usuario { margin-top: auto; padding: var(--e5); font-size: var(--t-xs); }
.usuario-nombre { font-weight: 600; color: var(--lat-blanco); font-size: var(--t-sm); }
.usuario-correo { color: var(--lat-tenue); word-break: break-all; }
.usuario .enlace { color: var(--cian); padding-left: 0; }
.version { font-size: var(--t-xs); color: var(--lat-version); padding: 0 var(--e5) var(--e5); }

.principal { min-width: 0; display: flex; flex-direction: column; }
.cabecera {
    position: sticky; top: 0; z-index: 30;
    height: var(--cabecera-h); display: flex; align-items: center; gap: var(--e4);
    padding: 0 var(--e6); background: var(--cabecera-fondo);
    backdrop-filter: blur(10px); border-bottom: 1px solid var(--borde);
}
.cabecera .espacio { margin-left: auto; }
.contenido { padding: var(--e6); max-width: var(--contenido-max); width: 100%; }
.pagina-cab { margin-bottom: var(--e5); }
.pagina-cab h1 { margin-bottom: var(--e2); }
.pagina-cab p { color: var(--texto2); max-width: 70ch; }
.migas { margin: 0 0 var(--e2); font-size: var(--t-sm); color: var(--tenue); }

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .lateral { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .lateral nav { flex-direction: row; flex-wrap: wrap; padding: var(--e3); }
    .nav-grupo { display: none; }
    .marca { padding: var(--e3) var(--e4); }
    .usuario { margin-top: 0; width: 100%; padding: 0 var(--e4) var(--e3); }
    .cabecera { padding: 0 var(--e4); }
    .contenido { padding: var(--e4) var(--e4) var(--e6); }
}

/* ── 13. DIÁLOGOS Y AVISOS EMERGENTES ───────────────────────────── */
.dialogo {
    border: 1px solid var(--borde); border-radius: var(--r-lg);
    padding: var(--e5); max-width: 480px; width: calc(100% - 2rem);
    color: var(--texto); background: var(--superficie); box-shadow: var(--sombra-3);
}
.dialogo::backdrop { background: var(--velo); }
.dialogo form { margin: 0; }
.dialogo h2 { margin-bottom: var(--e3); font-size: var(--t-lg); }
.dialogo p { color: var(--texto2); }
.dialogo-ancho { max-width: 720px; }
.dialogo-tres { max-width: 600px; }   /* tres botones en una fila */
.dialogo-cuerpo { max-height: 60vh; overflow-y: auto; margin-bottom: var(--e4); padding-right: var(--e1); }
.pieza-borrador { padding: var(--e3) 0; border-bottom: 1px solid var(--borde); }
.pieza-borrador:last-child { border-bottom: 0; }
.pieza-borrador .casilla { margin-bottom: var(--e2); }
.pieza-borrador .campo { margin-bottom: 0; }
.dialogo-acciones {
    display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--e2);
    margin: var(--e5) calc(var(--e5) * -1) calc(var(--e5) * -1);
    padding: var(--e4) var(--e5); border-top: 1px solid var(--borde);
    background: var(--superficie2); border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.toasts {
    position: fixed; right: var(--e5); bottom: var(--e5); z-index: 2000;
    display: flex; flex-direction: column; gap: var(--e2); max-width: min(92vw, 380px);
}
.toast {
    background: var(--toast-fondo); color: var(--toast-texto); border-radius: var(--r-md);
    padding: var(--e3) var(--e4); box-shadow: var(--sombra-3); font-size: var(--t-sm);
    animation: metis-toast var(--mov-2) both;
}
.toast-ok { background: var(--toast-fondo); }
.toast-error { background: var(--error-solido); }
@keyframes metis-toast { from { opacity: 0; transform: translateY(10px); } }

/* ── 14. ACCESO (login, restablecer, instalador, portada) ───────── */
.publico {
    min-height: 100vh;
    background:
        radial-gradient(90% 60% at 15% 0%, var(--portada-brillo) 0%, var(--portada-transp) 55%),
        linear-gradient(160deg, var(--portada-fondo) 0%, var(--fondo) 55%);
}
.acceso { max-width: 440px; margin: 0 auto; padding: var(--e7) var(--e4); }
.acceso-ancho { max-width: 680px; }
.acceso-marca { text-align: center; margin-bottom: var(--e5); }
.acceso-marca img { display: block; margin: 0 auto var(--e2); }
.wordmark {
    font-family: var(--f-titulo); font-size: var(--t-marca); font-weight: 700;
    letter-spacing: .14em; color: var(--wordmark); line-height: 1.1;
}
.lema { color: var(--tenue); font-size: var(--t-sm); }
.ix-lista { list-style: none; padding: 0; margin: 0; }
.ix-lista li { padding: var(--e2) 0; border-bottom: 1px solid var(--borde); font-size: var(--t-sm); }
.ix-ok strong { color: var(--ok); }
.ix-mal strong { color: var(--error); }

/* ── 15. ACCESO DEL ALUMNO ──────────────────────────────────────── */
.entrada-codigo {
    text-transform: uppercase; text-align: center; font-family: var(--f-mono);
    font-size: 1.3rem; letter-spacing: .08em;
}
.campo .entrada-codigo { height: 52px; }
.aviso-texto {
    max-height: 14rem; overflow-y: auto; background: var(--superficie2);
    border: 1px solid var(--borde); border-radius: var(--r-md);
    padding: var(--e3) var(--e4); margin-bottom: var(--e3); font-size: var(--t-sm);
}
.aviso-texto p:last-child { margin-bottom: 0; }

/* ── 16. SALUD DE MODELOS: mapa de calor ────────────────────────── */
.calor { border-collapse: separate; border-spacing: 2px; font-size: var(--t-xs); }
.calor th { position: static; background: none; font-weight: 600; color: var(--tenue); text-align: center; padding: 0 2px; border: 0; }
.calor td { min-width: 1.9rem; height: 1.7rem; text-align: center; border-radius: var(--r-sm); border: 0; padding: 0; }
.calor tbody tr:hover td { background: inherit; }
.calor td.calor-modelo { text-align: left; white-space: nowrap; padding-right: var(--e2); background: none; font-family: var(--f-mono); }
.calor-na { background: var(--superficie2); color: var(--tenue); }
.calor-0 { background: var(--calor-0); color: var(--ok); }
.calor-1 { background: var(--calor-1); color: var(--atencion); }
.calor-2 { background: var(--calor-2); color: var(--calor-2-tinta); }
.calor-3 { background: var(--calor-3); color: var(--calor-3-tinta); }
.calor-4 { background: var(--calor-4); color: var(--calor-4-tinta); }
.calor-poco { opacity: .5; }
.leyenda { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2); margin-top: var(--e3); }
.calor-muestra { display: inline-block; padding: 2px var(--e3); border-radius: var(--r-sm); font-size: var(--t-xs); }

/* ── 17. TARJETAS IMPRIMIBLES ───────────────────────────────────── */
.hoja-tarjetas { background: var(--imp-fondo); padding: var(--e4); }
.barra-tarjetas { margin-bottom: var(--e4); }
.rejilla-tarjetas {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px dashed var(--imp-corte); border-left: 1px dashed var(--imp-corte);
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.tarjeta {
    display: flex; flex-direction: column; overflow: hidden; background: var(--imp-fondo); break-inside: avoid;
    border-right: 1px dashed var(--imp-corte); border-bottom: 1px dashed var(--imp-corte); min-height: 17rem;
}
.t-franja { height: 7px; background: linear-gradient(90deg, var(--marino) 0%, var(--azul) 55%, var(--turquesa) 100%); }
.t-cabecera { display: flex; align-items: center; gap: var(--e2); padding: var(--e3) var(--e4) var(--e1); }
.t-logo { width: 38px; height: 38px; flex: none; }
.t-marca { font-family: var(--f-titulo); font-weight: 700; letter-spacing: .16em; color: var(--tinta-1); line-height: 1.1; font-size: 1.1rem; }
.t-lema { font-size: .68rem; color: var(--tenue); }
.t-cuerpo { padding: var(--e1) var(--e4); flex: 1; display: flex; flex-direction: column; gap: var(--e1); }
.t-nombre { font-family: var(--f-titulo); font-size: 1.3rem; font-weight: 700; color: var(--tinta-1); line-height: 1.15; word-break: break-word; }
.t-meta { font-size: .78rem; color: var(--tenue); }
.t-caja {
    margin: var(--e1) 0; padding: var(--e1) var(--e2); text-align: center;
    border-radius: var(--r-md); background: var(--imp-caja); border: 1.5px solid var(--azul);
}
.t-etiqueta { font-size: .62rem; text-transform: uppercase; letter-spacing: .12em; color: var(--tinta-3); font-weight: 700; }
.t-codigo { font-family: var(--f-mono); font-size: 1.3rem; font-weight: 700; letter-spacing: .06em; color: var(--tinta-1); }
.t-pasos { margin: 0; padding-left: 1.15rem; font-size: .76rem; line-height: 1.35; }
.t-pie {
    padding: var(--e1) var(--e4); font-size: .68rem; color: var(--tinta-2);
    text-align: center; background: var(--imp-caja); border-top: 1px solid var(--imp-caja-borde);
}

@media print {
    @page { margin: 10mm; size: A4; }
    body { background: var(--imp-fondo); }
    .no-imprimir { display: none !important; }
    .hoja-tarjetas { padding: 0; }
    .rejilla-tarjetas { grid-auto-rows: 68mm; }
    .tarjeta { min-height: 0; height: 68mm; }
    .t-logo { width: 32px; height: 32px; }
    .t-nombre { font-size: 1.15rem; }
    .t-pasos { font-size: .72rem; line-height: 1.25; }
    .t-codigo { font-size: 1.2rem; }
}

/* ═══════════════════════════════════════════════════════════════════
   18. CONSTRUCTOR (v0.4.0): editor por componentes (Mapa §8).
   Armazón, riel, segmentado, tablero, lista y ficha, piezas ordenables,
   escalera, ayuda de tarjeta, Gemini y vista previa del lienzo.
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --barra-ic-w: 56px;
    --riel-w: 240px;
    --riel-ic-w: 56px;
    --gemini-w: 340px;
}

/* ── A. ARMAZÓN DEL EDITOR ──────────────────────────────────────── */
.editor {
    display: grid; min-height: 100vh;
    grid-template-columns: var(--barra-ic-w) var(--riel-w) minmax(0, 1fr);
}
.editor.riel-contraido { grid-template-columns: var(--barra-ic-w) var(--riel-ic-w) minmax(0, 1fr); }
.editor.con-gemini { grid-template-columns: var(--barra-ic-w) var(--riel-w) minmax(0, 1fr) var(--gemini-w); }
.editor.riel-contraido.con-gemini { grid-template-columns: var(--barra-ic-w) var(--riel-ic-w) minmax(0, 1fr) var(--gemini-w); }

/* Barra lateral reducida a iconos */
.barra-ic {
    color: var(--lat-texto);
    background:
        linear-gradient(180deg, var(--lat-velo1) 0%, var(--lat-velo2) 48%, var(--lat-base) 100%),
        radial-gradient(160% 40% at 50% 0%, var(--lat-brillo) 0%, var(--lat-transp) 70%),
        var(--lat-color);
}
.barra-ic-int {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: var(--e4) 0;
}
.barra-ic .isotipo { width: 30px; height: 30px; margin-bottom: var(--e4); }
.barra-ic a {
    display: grid; place-items: center; width: 40px; height: 40px;
    border-radius: var(--r-md); color: var(--lat-enlace);
}
.barra-ic a:hover { background: var(--lat-hover); color: var(--lat-blanco); }
.barra-ic a[aria-current="page"] {
    background: linear-gradient(90deg, var(--lat-activo), var(--lat-activo2));
    color: var(--lat-blanco); box-shadow: inset 2px 0 0 var(--turquesa);
}
.barra-ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.barra-ic .avatar {
    margin-top: auto; width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center; font-size: var(--t-xs); font-weight: 700;
    background: var(--petroleo); color: #fff; border: 1px solid rgba(255, 255, 255, .25);
}

/* ── B. RIEL DE COMPONENTES ─────────────────────────────────────── */
.riel { background: var(--superficie2); border-right: 1px solid var(--borde); min-width: 0; }
.riel-int { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: var(--e3) var(--e2); }
.riel-cab {
    display: flex; align-items: center; justify-content: space-between;
    min-height: 34px; padding: 0 var(--e1) 0 var(--e3); margin-bottom: var(--e2);
    font-size: var(--t-xs); font-weight: 600; color: var(--tenue);
}
.riel-btn {
    display: grid; place-items: center; width: 30px; height: 30px; flex: none;
    border: 0; border-radius: var(--r-sm); background: transparent; color: var(--tenue); cursor: pointer;
}
.riel-btn:hover { background: var(--superficie3); color: var(--tinta-1); }
.riel-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.riel nav { display: flex; flex-direction: column; gap: 2px; }
.riel-item {
    position: relative; display: grid; grid-template-columns: 20px minmax(0, 1fr); column-gap: var(--e3);
    align-items: center; padding: var(--e2) var(--e3); border-radius: var(--r-md);
    color: var(--texto); text-decoration: none;
}
.riel-item:hover { background: var(--superficie3); }
.riel-item[aria-current="page"] { background: var(--superficie); box-shadow: var(--sombra-1), inset 3px 0 0 var(--turquesa); }
.riel-item > svg { width: 20px; height: 20px; fill: none; stroke: var(--tinta-3); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; grid-row: span 2; }
.riel-nombre { font-size: var(--t-md); font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.riel-item[aria-current="page"] .riel-nombre { color: var(--tinta-1); }
.riel-estado { display: flex; align-items: center; gap: 6px; font-size: var(--t-xs); color: var(--texto2); line-height: 1.4; white-space: nowrap; }
.riel-estado .cuenta { color: var(--tenue); }
.riel-estado .cuenta::before { content: ''; display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: var(--borde2); vertical-align: middle; margin: 0 6px 2px 0; }

/* Marca de estado: la forma distingue, el color acompaña */
.edo { width: 13px; height: 13px; flex: none; }
.edo-ok circle { fill: var(--ok-solido); }
.edo-ok path { fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.edo-prog circle { fill: none; stroke: var(--atencion); stroke-width: 1.5; }
.edo-prog path { fill: var(--atencion); }
.edo-vacio circle { fill: none; stroke: var(--tenue); stroke-width: 1.5; }

.riel-listo {
    margin-top: auto; padding: var(--e3); border-radius: var(--r-md);
    background: var(--superficie); border: 1px solid var(--borde);
    display: grid; grid-template-columns: 20px minmax(0, 1fr); column-gap: var(--e3); row-gap: var(--e2);
}
.riel-listo > svg { width: 20px; height: 20px; fill: none; stroke: var(--tinta-3); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.riel-listo b { font-size: var(--t-sm); color: var(--tinta-1); align-self: center; }
.riel-listo .chips { grid-column: 2; display: flex; flex-wrap: wrap; gap: var(--e1); }
.riel-listo .enlace { grid-column: 2; font-size: var(--t-sm); padding: 0; }

/* Riel contraído: solo iconos con su marca de estado */
.riel-contraido .riel-int { padding: var(--e3) var(--e1); align-items: center; }
.riel-contraido .riel-cab { padding: 0; justify-content: center; }
.riel-contraido .riel-cab span,
.riel-contraido .riel-texto,
.riel-contraido .riel-listo b,
.riel-contraido .riel-listo .chips,
.riel-contraido .riel-listo .enlace { display: none; }
.riel-contraido .riel-item { grid-template-columns: 20px; padding: 10px; justify-content: center; }
.riel-contraido .riel-item > svg { grid-row: auto; }
.riel-contraido .riel-item .edo { position: absolute; right: 5px; bottom: 5px; background: var(--superficie2); border-radius: 50%; box-shadow: 0 0 0 2px var(--superficie2); }
.riel-contraido .riel-item[aria-current="page"] .edo { background: var(--superficie); box-shadow: 0 0 0 2px var(--superficie); }
.riel-contraido .riel-listo { grid-template-columns: 20px; padding: 10px; position: relative; }
.riel-listo .globo { display: none; }
.riel-contraido .riel-listo .globo {
    display: grid; place-items: center; position: absolute; right: 2px; top: 2px;
    min-width: 17px; height: 17px; padding: 0 4px; border-radius: var(--r-pil);
    background: var(--error-solido); color: #fff; font-size: 11px; font-weight: 700;
}

/* ── C. CABECERA DEL EDITOR ─────────────────────────────────────── */
.area { min-width: 0; display: flex; flex-direction: column; container-type: inline-size; container-name: area; }
.cab-ed {
    position: sticky; top: 0; z-index: 30; height: var(--cabecera-h);
    display: flex; align-items: center; gap: var(--e3); padding: 0 var(--e5);
    background: var(--cabecera-fondo); backdrop-filter: blur(10px); border-bottom: 1px solid var(--borde);
}
.ruta { display: flex; align-items: center; gap: var(--e2); min-width: 0; font-size: var(--t-sm); }
.ruta a { color: var(--tenue); text-decoration: none; white-space: nowrap; }
.ruta a:hover { color: var(--tinta-3); }
.ruta .sep { color: var(--borde2); }
.ruta b { color: var(--texto); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.cab-ed .espacio { margin-left: auto; }
.sin-guardar { display: flex; align-items: center; gap: 6px; font-size: var(--t-sm); color: var(--atencion); white-space: nowrap; }
.sin-guardar::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--oro); }
.cab-ed .btn svg, .btn-ic svg { width: 17px; height: 17px; }

/* ── D. CABECERA DEL COMPONENTE ─────────────────────────────────── */
.contenido-ed { padding: var(--e5); width: 100%; max-width: 1180px; }
.comp-cab { margin-bottom: var(--e4); display: flex; align-items: flex-start; gap: var(--e4); }
.comp-cab > .comp-tit { min-width: 0; flex: 1; }
.comp-cab > .btn { flex: none; margin-top: var(--e1); }
.comp-cab h1 { display: flex; align-items: center; gap: var(--e3); flex-wrap: wrap; margin-bottom: var(--e1); }
.comp-cab h1 .chip { font-family: var(--f-texto); }
.comp-cab p { color: var(--texto2); margin: 0; max-width: 70ch; }
.contenido-ed .pestanas { margin-bottom: var(--e4); scrollbar-width: none; }
.contenido-ed .pestanas::-webkit-scrollbar { display: none; }

/* ── E. BOTÓN SEGMENTADO (2 o 3 valores) ────────────────────────── */
.seg {
    display: inline-flex; height: var(--d-campo); padding: 2px; gap: 2px;
    border: 1px solid var(--borde2); border-radius: var(--r-md); background: var(--superficie);
}
.seg label { position: relative; display: flex; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg span {
    display: flex; align-items: center; padding: 0 var(--e3); border-radius: var(--r-sm);
    font-size: var(--t-sm); font-weight: 600; color: var(--texto2); cursor: pointer; white-space: nowrap;
}
.seg span:hover { background: var(--superficie2); color: var(--texto); }
.seg input:checked + span { background: var(--relleno); color: var(--sobre-relleno); }
.seg input:focus-visible + span { box-shadow: var(--anillo); }
.campo .seg { display: inline-flex; }

/* Etiqueta de campo con acciones (Gemini, obligatorio) */
.campo > span.etq { display: flex; align-items: center; gap: var(--e1); }
.req { color: var(--error); font-weight: 700; }
.btn-gemini {
    display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0;
    border: 0; border-radius: var(--r-sm); background: transparent; color: var(--acento); cursor: pointer;
}
.btn-gemini:hover, .btn-gemini.activo { background: var(--info-fondo); }
.btn-gemini svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }
.gemini-txt { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); font-weight: 600; color: var(--info); background: none; border: 0; cursor: pointer; padding: 0; }
.gemini-txt svg { width: 15px; height: 15px; fill: currentColor; }

/* Anchos de campo por contenido (DISENO §8 bis) */
.c-min input, .c-min select { width: 64px; }
.c-cor input, .c-cor select { width: 140px; }
.c-med input, .c-med select { width: 240px; }
.c-lec textarea, .c-lec input { max-width: 70ch; }
.campo textarea.t2 { min-height: 0; height: 64px; }
.campo textarea.t3 { min-height: 0; height: 84px; }

/* Fila de campos de ancho natural (no estira) */
.fila { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--e3) var(--e4); }
.fila > .campo { margin-bottom: var(--e3); }
.fila-2 { display: grid; gap: var(--e4); grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.fila-3 { display: grid; gap: var(--e3); grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); }

/* ── F. TABLERO DE AJUSTES ──────────────────────────────────────── */
.tablero { display: grid; gap: var(--e4); grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); margin-bottom: var(--e4); }
.ajuste { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-lg); padding: var(--e4); box-shadow: var(--sombra-1); }
.ajuste h3, .card h3.t { font-size: var(--t-lg); margin: 0 0 var(--e3); }
.ajuste .nota { font-size: var(--t-xs); margin: var(--e2) 0 0; }
.ajuste .valor { display: flex; align-items: center; gap: var(--e2); flex-wrap: wrap; font-size: var(--t-md); font-weight: 600; }
.ajuste .campo { margin-bottom: 0; }
.rejilla-ed { display: grid; gap: var(--e4); grid-template-columns: minmax(0, 1.6fr) minmax(380px, 1fr); align-items: start; }
.rejilla-ed > .card, .col > .card, .col > .ajuste { margin-bottom: 0; }
.col { display: flex; flex-direction: column; gap: var(--e4); min-width: 0; }
.contenido-ed .card { padding: var(--e4) var(--e5); margin-bottom: var(--e4); }

/* ── G. MAESTRO-DETALLE ─────────────────────────────────────────── */
.md { display: grid; gap: var(--e4); grid-template-columns: 272px minmax(0, 1fr); align-items: start; }
.md-lista { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-lg); padding: var(--e2); box-shadow: var(--sombra-1); }
.md-lista .btn { width: 100%; margin-bottom: var(--e2); }
.md-grupo { font-size: var(--t-xs); font-weight: 600; color: var(--tenue); padding: var(--e3) var(--e2) var(--e1); }
.md-fila {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--e2);
    height: 36px; padding: 0 var(--e2); border-radius: var(--r-sm);
    font-size: var(--t-sm); color: var(--texto); text-decoration: none;
}
.md-fila:hover { background: var(--superficie2); }
.md-fila[aria-current="true"] { background: var(--info-fondo); box-shadow: inset 3px 0 0 var(--turquesa); }
.md-fila .codigo { font-size: var(--t-xs); color: var(--tinta-3); }
.md-fila .txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-fila .der { display: flex; align-items: center; gap: var(--e1); font-size: var(--t-xs); color: var(--tenue); }
.md-pie { font-size: var(--t-xs); color: var(--tenue); padding: var(--e2) var(--e2) var(--e1); }
.md-selector { display: none; }

/* Ficha */
.ficha-cab { display: flex; align-items: flex-start; gap: var(--e3); margin-bottom: var(--e3); }
.ficha-cab h2 { font-size: var(--t-lg); margin: 0; display: flex; align-items: center; gap: var(--e2); flex-wrap: wrap; }
.ficha-cab .chips { margin-top: var(--e2); }
.ficha-cab .der { margin-left: auto; display: flex; gap: var(--e2); flex: none; }
.cod {
    font-family: var(--f-mono); font-size: var(--t-xs); font-weight: 600; letter-spacing: .02em;
    color: var(--tinta-3); background: var(--superficie2); border: 1px solid var(--borde);
    padding: 2px 7px; border-radius: var(--r-sm); white-space: nowrap;
}
.chips { display: flex; flex-wrap: wrap; gap: var(--e1) 6px; align-items: center; }
.rotulo { font-size: var(--t-sm); font-weight: 600; color: var(--texto2); margin: 0 0 6px; display: flex; align-items: center; gap: var(--e1); }
.bloque { margin-bottom: var(--e4); }

/* Referencia a otra pieza (fuente, hecho, pista) */
.ref {
    display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 var(--e2);
    border: 1px solid var(--borde2); border-radius: var(--r-sm); background: var(--superficie);
    font-size: var(--t-sm); color: var(--texto); white-space: nowrap;
}
.ref .cod { padding: 0; border: 0; background: none; }
.ref .tipo { color: var(--tenue); font-size: var(--t-xs); }
.ref svg { width: 14px; height: 14px; fill: none; stroke: var(--tenue); stroke-width: 1.8; }

/* Pestañas internas de una ficha */
.pest-int { display: flex; gap: var(--e1); border-bottom: 1px solid var(--borde); margin: 0 0 var(--e4); overflow-x: auto; scrollbar-width: none; }
.pest-int button {
    display: flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer;
    border: 0; background: none; padding: var(--e2) var(--e2) 9px; margin-bottom: -1px;
    font: inherit; font-size: var(--t-sm); font-weight: 600; color: var(--tenue); border-bottom: 2px solid transparent;
}
.pest-int button[aria-selected="true"] { color: var(--tinta-2); border-bottom-color: var(--acento); }
.pest-int .n { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--superficie3); font-size: 11px; color: var(--texto2); }
.pest-int button[aria-selected="true"] .n { background: var(--relleno); color: var(--sobre-relleno); }
.pest-int svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }

/* Avisos con icono */
.aviso-ic { display: flex; gap: var(--e2); align-items: flex-start; }
.aviso-ic > svg { width: 17px; height: 17px; flex: none; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ── H. PANEL DE GEMINI ─────────────────────────────────────────── */
.gemini {
    background: var(--superficie); border-left: 1px solid var(--borde); box-shadow: var(--sombra-2);
    min-width: 0; z-index: 40;
}
.gemini-int { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: var(--e4) var(--e5); display: flex; flex-direction: column; }
.gemini-int > * { flex-shrink: 0; }   /* con una propuesta larga, nada se aplasta: el panel se desplaza */
.gemini-cab { display: flex; align-items: center; gap: var(--e2); margin-bottom: var(--e1); }
.gemini-cab h2 { font-size: var(--t-lg); margin: 0; color: var(--tinta-1); }
.gemini-cab > svg { width: 18px; height: 18px; fill: var(--acento); }
.gemini-cab .riel-btn { margin-left: auto; }
.gemini .contexto { font-size: var(--t-xs); color: var(--tenue); margin-bottom: var(--e4); }
.propuesta { background: var(--info-fondo); border: 1px solid var(--info-borde); border-radius: var(--r-md); padding: var(--e3) var(--e4); margin: var(--e4) 0 var(--e3); }
.propuesta .rotulo { color: var(--info); }
.propuesta p { margin: 0; font-size: var(--t-md); }
.gemini .nota { font-size: var(--t-xs); margin-top: var(--e3); }

/* ── I. LÍNEA VERTICAL Y PIEZAS ORDENABLES ──────────────────────── */
.linea { position: relative; padding-left: 30px; }
.linea::before { content: ''; position: absolute; left: 9px; top: 10px; bottom: 10px; width: 2px; background: var(--borde2); }
.nodo { position: relative; margin-bottom: var(--e2); }
.nodo::before {
    content: ''; position: absolute; left: -27px; top: 50%; width: 14px; height: 14px; margin-top: -7px;
    border-radius: 50%; background: var(--fondo); border: 2px solid var(--borde2);
}
.nodo.activo::before { border-color: var(--acento); background: var(--superficie); box-shadow: 0 0 0 3px var(--info-fondo); }
.nodo.abierto::before { top: 23px; }
.nodo.rombo::before { border-radius: 2px; transform: rotate(45deg); width: 11px; height: 11px; margin-top: -6px; left: -25.5px; }
.nodo-txt { font-size: var(--t-sm); font-weight: 600; color: var(--texto2); padding: var(--e1) 0; }
.nodo.rombo .nodo-txt { font-weight: 400; color: var(--tenue); }

.orden {
    background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-md); box-shadow: var(--sombra-1);
}
.orden.abierto { border-color: var(--acento); box-shadow: var(--sombra-1), 0 0 0 1px var(--acento); }
.orden-cab { display: flex; align-items: center; gap: var(--e2); min-height: 46px; padding: var(--e1) var(--e2) var(--e1) var(--e1); }
.asa { display: grid; place-items: center; width: 24px; height: 30px; color: var(--borde2); cursor: grab; flex: none; }
.asa svg { width: 14px; height: 14px; fill: currentColor; }
.orden-cab .num { font-family: var(--f-titulo); font-size: var(--t-lg); font-weight: 700; color: var(--tenue); width: 18px; text-align: center; flex: none; }
.orden-tit { font-weight: 600; font-size: var(--t-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.orden-cab .chips { flex-wrap: nowrap; overflow: hidden; }
.orden-cab .meta { margin-left: auto; display: flex; align-items: center; gap: var(--e3); flex: none; font-size: var(--t-sm); color: var(--texto2); white-space: nowrap; }
.orden-cab .meta svg, .ico-sm { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; }
.alerta { display: inline-flex; align-items: center; gap: 4px; color: var(--error); font-weight: 600; font-size: var(--t-xs); }
.alerta svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; }
.chev { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: var(--r-sm); background: none; color: var(--tenue); cursor: pointer; flex: none; }
.chev:hover { background: var(--superficie2); }
.chev svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.orden-cuerpo { padding: 0 var(--e4) var(--e4) 38px; }
.cols-auto { display: grid; gap: var(--e3) var(--e4); grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
.mini-lista { display: flex; flex-direction: column; gap: 6px; }
.mini {
    display: flex; align-items: center; gap: var(--e2); padding: 6px var(--e2);
    background: var(--superficie2); border-radius: var(--r-sm); font-size: var(--t-sm);
}
.mini.flecha { background: none; padding: 0 0 0 var(--e3); color: var(--tenue); font-size: var(--t-xs); }

/* Barra de tiempo */
.barra-tiempo { display: flex; height: 12px; border-radius: var(--r-pil); overflow: hidden; gap: 2px; margin: var(--e2) 0; }
.barra-tiempo i { display: block; }
.bt-1 { background: var(--marino); } .bt-2 { background: var(--petroleo); } .bt-3 { background: var(--azul); } .bt-4 { background: var(--agua); }
.bt-cierre { background: repeating-linear-gradient(135deg, var(--borde2) 0 4px, var(--superficie3) 4px 8px); }
.leyenda-t { display: flex; flex-wrap: wrap; gap: var(--e1) var(--e3); font-size: var(--t-xs); color: var(--texto2); }
.leyenda-t span { display: inline-flex; align-items: center; gap: 5px; }
.leyenda-t i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }

/* Lista de revisión */
.revision { list-style: none; margin: 0; padding: 0; }
.revision li { display: flex; gap: var(--e2); padding: var(--e2) 0; border-bottom: 1px solid var(--borde); font-size: var(--t-sm); }
.revision li:last-child { border-bottom: 0; }
.revision svg { width: 16px; height: 16px; flex: none; margin-top: 2px; fill: none; stroke-width: 2; stroke-linecap: round; }
.revision .e svg { stroke: var(--error); }
.revision .a svg { stroke: var(--atencion); }

/* ── J. ESCALERA DE PISTAS ──────────────────────────────────────── */
.escalera { position: relative; padding-left: 40px; }
.escalera::before { content: ''; position: absolute; left: 13px; top: 18px; bottom: 18px; width: 2px; background: var(--borde2); }
.escalon { position: relative; margin-bottom: var(--e2); }
.escalon .marca-e {
    position: absolute; left: -40px; top: 9px; width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center; font-size: var(--t-sm); font-weight: 700;
    background: var(--superficie); border: 2px solid var(--borde2); color: var(--texto2);
}
.escalon .marca-e svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.escalon.activo .marca-e { background: var(--relleno); border-color: var(--relleno); color: var(--sobre-relleno); }
.escalon.inactivo .orden-tit, .escalon.inactivo .marca-e { color: var(--tenue); }
.escalon .orden-cab { padding-left: var(--e3); }
.escalon .resumen { font-size: var(--t-sm); color: var(--texto2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.escalon .orden-cuerpo { padding-left: var(--e3); }

/* ── K. TEMA Y VISTA PREVIA ─────────────────────────────────────── */
.color-fila { display: grid; grid-template-columns: 28px minmax(0, 1fr) 104px 112px; align-items: center; gap: var(--e3); padding: 6px 0; border-bottom: 1px solid var(--borde); }
.color-fila:last-of-type { border-bottom: 0; }
.muestra { width: 28px; height: 28px; border-radius: var(--r-sm); border: 1px solid rgba(0, 0, 0, .12); }
.color-fila .campo { margin: 0; }
.color-fila input { font-family: var(--f-mono); font-size: var(--t-sm); }
.color-fila .nombre { font-size: var(--t-sm); }
.contraste { justify-self: start; }

/* Lienzo del alumno: aquí, y solo aquí, mandan los colores del escape room */
.lienzo {
    --l-fondo: #050b07; --l-sup: #0d1a11; --l-acento: #39ff6a; --l-texto: #ddebe0; --l-texto2: #6f8f76;
    position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-md); overflow: hidden;
    background:
        radial-gradient(60% 50% at 30% 60%, rgba(57, 255, 106, .10), transparent 70%),
        radial-gradient(40% 40% at 75% 25%, rgba(57, 255, 106, .06), transparent 70%),
        linear-gradient(180deg, #08130b, var(--l-fondo));
    border: 1px solid var(--borde);
}
.lienzo .consola {
    position: absolute; left: 6%; right: 6%; bottom: 0; height: 34%;
    background: linear-gradient(180deg, #0f2215, #07100a); border-top: 2px solid rgba(57, 255, 106, .25);
}
.lienzo .monitor { position: absolute; border: 1px solid rgba(57, 255, 106, .35); background: rgba(57, 255, 106, .05); border-radius: 3px; }
.lienzo .silueta {
    position: absolute; left: 14%; bottom: 0; width: 17%; height: 74%;
    background: radial-gradient(48% 22% at 50% 14%, #020503 98%, transparent 100%), radial-gradient(70% 70% at 50% 100%, #020503 98%, transparent 100%);
}
.lienzo .ui-juego { position: absolute; top: 4%; right: 3%; display: flex; gap: 6px; }
.lienzo .ui-juego i { width: 26px; height: 26px; border: 1px solid var(--l-acento); border-radius: 4px; display: grid; place-items: center; color: var(--l-acento); font-style: normal; font-size: 13px; font-weight: 700; }
.lienzo .modal-j {
    position: absolute; right: 6%; top: 22%; width: 52%; padding: 4% 4.5%;
    background: rgba(13, 26, 17, .92); border: 1px solid var(--l-acento); border-radius: 4px;
    color: var(--l-texto); box-shadow: 0 0 24px rgba(57, 255, 106, .15);
}
.lienzo .modal-j b { display: block; font-family: var(--f-titulo); color: var(--l-acento); font-size: clamp(14px, 2.4cqi, 22px); margin-bottom: 4%; }
.lienzo .modal-j p { font-size: clamp(11px, 1.55cqi, 15px); line-height: 1.45; margin: 0 0 6%; }
.lienzo .modal-j span { display: block; text-align: center; border: 1px solid var(--l-acento); color: var(--l-acento); border-radius: 3px; padding: 2.4% 0; font-weight: 700; font-size: clamp(11px, 1.4cqi, 14px); }
.vista { container-type: inline-size; }

/* ── L. DIÁLOGO DE IMPORTACIÓN ──────────────────────────────────── */
.archivo { display: flex; gap: var(--e3); align-items: center; padding: var(--e3); border: 1px solid var(--borde); border-radius: var(--r-md); background: var(--superficie2); margin-bottom: var(--e4); }
.archivo svg { width: 28px; height: 28px; fill: none; stroke: var(--tinta-3); stroke-width: 1.6; flex: none; }
.archivo .nombre { font-family: var(--f-mono); font-size: var(--t-sm); font-weight: 600; overflow-wrap: anywhere; }
.archivo .nota { font-size: var(--t-xs); }
.ficha-arch { display: grid; grid-template-columns: max-content 1fr; gap: 2px var(--e4); font-size: var(--t-sm); margin: 0 0 var(--e4); }
.ficha-arch dt { color: var(--tenue); }
.ficha-arch dd { margin: 0; }
.conteo { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--e4); }
.dialogo-informe .dialogo-acciones { border-top: 1px solid var(--borde); padding-top: var(--e4); margin-top: var(--e2); }


/* ── M. ADAPTACIÓN ──────────────────────────────────────────────── */
/* Gemini por debajo de 1280 px: se superpone en lugar de empujar */
@media (max-width: 1279px) {
    .editor.con-gemini { grid-template-columns: var(--barra-ic-w) var(--riel-w) minmax(0, 1fr); }
    .editor.riel-contraido.con-gemini { grid-template-columns: var(--barra-ic-w) var(--riel-ic-w) minmax(0, 1fr); }
    .gemini { position: fixed; right: 0; top: 0; bottom: 0; width: var(--gemini-w); max-width: 92vw; box-shadow: var(--sombra-3); }
}
/* Según el ancho real del área de trabajo */
@container area (max-width: 980px) {
    .md { grid-template-columns: 236px minmax(0, 1fr); }
}
@container area (max-width: 820px) {
    .rejilla-ed { grid-template-columns: minmax(0, 1fr); }
}
@container area (max-width: 760px) {
    .contenido-ed { padding: var(--e4); }
    .md { grid-template-columns: minmax(0, 1fr); }
    .md-lista { display: none; }
    .md-selector {
        display: flex; align-items: center; gap: var(--e2); margin-bottom: var(--e3);
        background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-md); padding: var(--e2);
    }
    .md-selector .campo { flex: 1; margin: 0; }
    .ficha-cab { flex-wrap: wrap; }
    .orden-cab .chips .opc { display: none; }
    .cab-ed { padding: 0 var(--e4); gap: var(--e2); }
    .color-fila { grid-template-columns: 28px minmax(0, 1fr) 96px; }
    .color-fila .contraste { grid-column: 2 / -1; }
}
@container area (max-width: 700px) {
    .ruta a, .ruta .sep { display: none; }
}
@container area (max-width: 600px) {
    .cab-ed .txt-largo { display: none; }
}

/* ── N. AJUSTES FINOS ───────────────────────────────────────────── */
.campo > span.etq:empty { display: none; }
.fila > .palanca { margin-bottom: 18px; }
.edo-c { display: none; }
.riel-contraido .edo-c { display: block; position: absolute; right: 5px; bottom: 5px; line-height: 0; border-radius: 50%; background: var(--superficie2); box-shadow: 0 0 0 2px var(--superficie2); }
.riel-contraido .riel-item[aria-current="page"] .edo-c { background: var(--superficie); box-shadow: 0 0 0 2px var(--superficie); }
.riel-contraido .riel-item .riel-estado .edo { position: static; }
.rejilla-ed.rec { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
.rejilla-ed.tema { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }

/* Personajes */
.personajes { display: flex; flex-wrap: wrap; gap: var(--e4); margin-bottom: var(--e4); }
.pj { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 72px; font-size: var(--t-xs); color: var(--texto2); text-decoration: none; text-align: center; }
.pj span {
    display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
    background: var(--superficie3); color: var(--tinta-3); font-family: var(--f-titulo); font-weight: 700; font-size: var(--t-lg);
    border: 2px solid transparent;
}
.pj.activo { color: var(--tinta-1); font-weight: 600; }
.pj.activo span { border-color: var(--acento); background: var(--info-fondo); box-shadow: 0 0 0 3px var(--info-fondo); }
.pj.nuevo span { background: none; border: 2px dashed var(--borde2); color: var(--tenue); }
.pj.nuevo svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.pj-ficha { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: var(--e4); }
.retrato {
    width: 128px; height: 128px; border-radius: var(--r-md); background: var(--superficie2); border: 1px dashed var(--borde2);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    font-size: var(--t-xs); color: var(--tenue); text-align: center; line-height: 1.3;
}
.retrato svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.6; }
@container area (max-width: 520px) {
    .pj-ficha { grid-template-columns: minmax(0, 1fr); }
}
@container area (max-width: 820px) {
    .rejilla-ed.rec, .rejilla-ed.tema { grid-template-columns: minmax(0, 1fr); }
}
.contenido-ed .campo textarea, .gemini .campo textarea { font-family: var(--f-texto); font-size: var(--t-md); line-height: 1.45; padding: 6px var(--e3); }
.c-cor2 input, .c-cor2 select { width: 190px; }
.rango { display: flex; align-items: center; gap: var(--e2); color: var(--tenue); font-size: var(--t-sm); }
.campo .rango input { width: 56px; }
.menu-panel button { white-space: nowrap; }
.fila > .c-lec { flex: 1 1 340px; }

/* Pestañas que no caben: se desplazan y el borde derecho se desvanece */
.pestanas.desborda, .pest-int.desborda { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 48px), transparent); }

.orden-cab .orden-tit { flex: 1 1 auto; }
.orden-cab .chips { flex: none; }

.escalon .orden-tit { flex: none; }
.escalon .resumen { flex: 1 1 auto; }
.escalon .chev { margin-left: auto; }

.orden-cab .orden-tit { min-width: 9em; }
.orden-cab .chips { flex: 0 1 auto; min-width: 0; }
.c-hora input { width: 84px; }
.color-fila { grid-template-columns: 28px minmax(0, 1fr) 104px 136px; }
.rango i { font-style: normal; }
.riel-contraido .edo-c { right: 4px; bottom: 4px; }
.riel-contraido .edo-c .edo { width: 11px; height: 11px; }
.fila-3 { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
/* Tablet vertical: Gemini abre como hoja inferior para no tapar el campo */
@media (max-width: 900px) {
    .gemini { top: auto; left: var(--barra-ic-w); width: auto; max-width: none; height: 52vh; border-left: 0; border-top: 1px solid var(--borde); border-radius: var(--r-lg) var(--r-lg) 0 0; }
    .gemini-int { height: 100%; position: static; }
    .editor.con-gemini .contenido-ed { padding-bottom: 54vh; }
}
@media (max-width: 900px) {
    .riel-contraido .gemini { left: calc(var(--barra-ic-w) + var(--riel-ic-w)); }
    .editor:not(.riel-contraido) .gemini { left: calc(var(--barra-ic-w) + var(--riel-w)); }
}
/* Las etiquetas nunca se cortan: cede el título */
.orden-cab .orden-tit { min-width: 4em; }
.orden-cab .chips { flex: none; overflow: visible; }
@container area (max-width: 980px) { .orden-cab .chips .opc { display: none; } }

/* ── Ayuda de tarjeta (?) ── */
.btn-ayuda {
    display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0; margin-left: var(--e1);
    border: 0; border-radius: 50%; background: transparent; color: var(--tenue); cursor: help; vertical-align: middle;
}
.btn-ayuda:hover, .btn-ayuda[aria-expanded="true"] { color: var(--acento); background: var(--info-fondo); }
.btn-ayuda svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.globo-ayuda {
    position: fixed; z-index: 90; width: min(480px, calc(100vw - 16px)); max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px); overflow-y: auto; overscroll-behavior: contain;
    background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-md);
    box-shadow: var(--sombra-3); padding: var(--e3) var(--e4); font-family: var(--f-texto);
    font-size: var(--t-sm); font-weight: 400; line-height: 1.5; color: var(--texto); letter-spacing: 0;
}
.globo-ayuda b { display: block; font-size: var(--t-xs); color: var(--tinta-3); margin-top: var(--e2); }
.globo-ayuda b:first-child { margin-top: 0; }
.globo-ayuda p { margin: 2px 0 0; }
.globo-ayuda ul { margin: 2px 0 0; padding: 0; list-style: none; }
.globo-ayuda li { margin-top: var(--e1); }
.globo-ayuda li:first-child { margin-top: 0; }
.globo-ayuda .ay-c { font-weight: 600; color: var(--tinta-2); }
.globo-ayuda .ay-b { margin-top: var(--e2); }
/* Ancho (el script elige el ancho que deja el globo en 16:9 o más apaisado): dos bloques lado a lado. */
.globo-ayuda.ancho { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 0 var(--e5); }
.globo-ayuda.ancho .ay-b { margin-top: 0; padding-left: var(--e5); border-left: 1px solid var(--borde); }
.globo-ayuda.ancho2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.globo-ayuda.ancho2 .ay-b ul { column-count: 2; column-gap: var(--e5); }
.globo-ayuda li { break-inside: avoid; }
.globo-ayuda .ej { color: var(--texto2); font-style: italic; margin-top: var(--e2); }
h3.t, .ajuste h3 { display: flex; align-items: center; gap: 2px; }

/* ── Contexto que verá Gemini ── */
.ctx { margin-bottom: var(--e4); }
.ctx .rotulo { margin-bottom: 4px; }
.ctx .chips { margin-bottom: var(--e2); }
.ctx-falta .chip { cursor: default; }
.gemini .acciones { margin-top: var(--e2); }
.gemini .err { color: var(--error); font-size: var(--t-sm); margin-top: var(--e2); }

/* ── Componentes que llegan en otra entrega ── */
.proximo { max-width: 62ch; }
.proximo ul { margin: var(--e2) 0 var(--e4); padding-left: 1.2rem; color: var(--texto2); }
.proximo li { margin-bottom: 4px; }

/* ── Piezas de Aprendizaje ── */
.fuente-fila { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto auto; gap: var(--e2); align-items: center; margin-bottom: var(--e2); }
.fuente-fila .campo { margin: 0; }
.fuente-fila .casilla { margin: 0; white-space: nowrap; font-size: var(--t-sm); }
.matriz td, .matriz th { text-align: center; }
.matriz td:first-child, .matriz th:first-child { text-align: left; }
.marca-si { color: var(--ok); font-weight: 700; }
.marca-dec { color: var(--tinta-3); font-weight: 700; }
.ficha-asig { border: 1px solid var(--borde); border-radius: var(--r-md); padding: var(--e3) var(--e4); margin-bottom: var(--e3); background: var(--superficie); }
.ficha-asig-cab { display: flex; align-items: center; gap: var(--e2); margin-bottom: var(--e2); }
.ficha-asig-cab b { font-size: var(--t-md); }
.ficha-asig-cab .btn { margin-left: auto; }
/* Ficha de asignatura en dos columnas (101A); una sola con 820 px o menos de área. */
.rej-ficha { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--e4); align-items: start; }
.rej-ficha .campo { margin-bottom: var(--e3); }
.rej-ficha .pila { display: flex; flex-direction: column; }
@container area (max-width: 820px) {
    .rej-ficha { grid-template-columns: minmax(0, 1fr); }
}
.escala td:nth-child(2) { font-weight: 700; color: var(--tinta-3); }
.escala td:first-child { white-space: nowrap; }
@container area (max-width: 760px) {
    .fuente-fila { grid-template-columns: minmax(0, 1fr) auto; }
    .fuente-fila .campo:first-child { grid-column: 1 / -1; }
}
.riel-listo .nota { grid-column: 1 / -1; font-size: var(--t-xs); margin: 0; }
.riel-contraido .riel-listo .nota { display: none; }
.md-cab { display: flex; align-items: center; gap: 2px; padding: var(--e1) var(--e2) var(--e2); font-size: var(--t-sm); color: var(--tinta-1); }
.marca-ic { width: auto; height: auto; }
.ficha-cab .der { align-items: center; }
@container area (max-width: 760px) {
    .fuente-fila { grid-template-columns: minmax(0, 1fr) auto auto; }
    .fuente-fila .campo:first-child { grid-column: 1 / -1; }
}

/* ── R. HISTORIA Y MISIÓN (v0.4.3) ──────────────────────────────── */
/* Rejilla de dos columnas para formularios de una tarjeta; una sola con 820 px o menos de área. */
.rej-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--e4); align-items: start; }
.rej-2 .campo { margin-bottom: var(--e3); }
@container area (max-width: 820px) { .rej-2 { grid-template-columns: minmax(0, 1fr); } }
h3.t .der { margin-left: auto; display: flex; align-items: center; gap: var(--e3); font-family: var(--f-texto); font-weight: 400; }
.aviso-borrador { display: flex; align-items: center; gap: var(--e4); flex-wrap: wrap; margin-bottom: var(--e4); }
.aviso-borrador > span { flex: 1 1 360px; }
.aviso-borrador .gemini-txt { flex: none; }
.pestanas .cuenta-aviso { background: var(--atencion-fondo); color: var(--atencion); }
.chip-info { background: var(--info-fondo); color: var(--info); border-color: var(--info-borde); }
.chip-info::before { display: none; }
.revision li.err { color: var(--error); }
.revision li.ok { color: var(--ok); }
.tenue { color: var(--tenue); }
#con-tablas h4 { font-size: var(--t-md); color: var(--tinta-2); margin: var(--e4) 0 var(--e2); }

/* Renglones de una pieza por fila (hechos, objetivos, variables): código, campos y acciones. */
.renglones { margin-bottom: var(--e3); }
.renglon { display: grid; gap: var(--e3); align-items: start; padding: var(--e2) 0; border-bottom: 1px solid var(--borde); }
.renglon .campo { margin-bottom: 0; }
.renglon > .cod { margin-top: var(--e2); justify-self: start; }
.renglon .acc { display: flex; gap: var(--e1); margin-top: 3px; }
.renglon-cab { padding: 0 0 var(--e1); font-size: var(--t-sm); font-weight: 600; color: var(--texto2); }
.campo.con-gem { position: relative; }
.campo.con-gem textarea { padding-right: var(--e6); }
.campo.con-gem .btn-gemini { position: absolute; top: var(--e1); right: var(--e1); }
.r-hecho { grid-template-columns: 52px minmax(0, 1fr) 230px 102px; }
.r-obj { grid-template-columns: 52px minmax(0, 1fr) 102px; }
.r-var { grid-template-columns: 52px minmax(0, .7fr) minmax(0, 1fr) minmax(0, 1.5fr) 102px; }
.r-comp { grid-template-columns: 52px minmax(0, .8fr) minmax(0, 1.6fr) 102px; }
@container area (max-width: 820px) {
    .renglon-cab.r-hecho, .renglon-cab.r-var, .renglon-cab.r-comp { display: none; }
    .r-hecho .campo[data-etq]::before, .r-var .campo[data-etq]::before, .r-comp .campo[data-etq]::before {
        content: attr(data-etq); display: block; font-size: var(--t-xs); font-weight: 600; color: var(--texto2); margin-bottom: var(--e1);
    }
    .r-hecho, .r-var, .r-comp { grid-template-columns: 52px minmax(0, 1fr) 102px; }
    .r-hecho > .campo:nth-of-type(2), .r-var > .campo:nth-of-type(n+2), .r-comp > .campo:nth-of-type(2) { grid-column: 2 / 3; }
    .r-hecho .acc, .r-var .acc, .r-comp .acc { grid-column: 3; grid-row: 1; }
}

/* Personaje: hechos que conoce. */
.hechos-p { border: 1px solid var(--borde); border-radius: var(--r-md); padding: var(--e1) var(--e3); margin-bottom: var(--e2); }
.hecho-p { display: flex; align-items: center; gap: var(--e3); padding: var(--e2) 0; border-bottom: 1px solid var(--borde); }
.hecho-p:last-child { border-bottom: 0; }
.hecho-p .casilla { margin: 0; align-items: flex-start; }
.hecho-p > .casilla:first-child { flex: 1; min-width: 0; font-size: var(--t-sm); }
.hecho-p .revela { flex: none; font-size: var(--t-sm); }

/* Finales con su condición. */
.final-ficha { border: 1px solid var(--borde); border-radius: var(--r-md); padding: var(--e3) var(--e4); margin-bottom: var(--e3); }
.final-ficha .ficha-cab h2 { flex: 1; min-width: 0; }
.nombre-final { flex: 1; min-width: 0; font: inherit; font-size: var(--t-md); font-weight: 600; color: var(--texto); border: 1px solid transparent; border-radius: var(--r-sm); padding: var(--e1) var(--e2); background: transparent; }
.nombre-final:hover { border-color: var(--borde); }
.nombre-final:focus { outline: none; border-color: var(--tinta-3); box-shadow: var(--anillo); background: var(--superficie); }
.final-ficha .acc { display: flex; gap: var(--e1); }
.reglas { display: flex; flex-direction: column; gap: var(--e1); margin-bottom: var(--e2); }
.regla { display: flex; align-items: center; flex-wrap: wrap; gap: var(--e2) var(--e3); padding: var(--e2) var(--e3); background: var(--superficie2); border-radius: var(--r-sm); font-size: var(--t-sm); }
.regla .casilla { margin: 0; }
.regla .btn { margin-left: auto; }
.reglas .y { font-size: var(--t-xs); font-weight: 700; color: var(--tenue); text-transform: uppercase; padding-left: var(--e3); }

/* Propuesta de Gemini por bloques. */
.prop-bloque { padding: var(--e2) 0; border-bottom: 1px solid var(--borde); }
.prop-bloque:last-child { border-bottom: 0; }
.prop-bloque .casilla { margin: 0 0 var(--e1); }
.prop-valor { padding-left: var(--e5); font-size: var(--t-sm); }
.prop-valor p, .prop-valor li { margin: 0 0 var(--e1); font-size: var(--t-sm); }
.prop-valor ul { margin: 0; padding-left: var(--e4); }
.prop-valor li { margin-bottom: var(--e2); }

/* ── S. TEXTOS QUE EXCEDEN SU TOPE (105A) ──────────────────────── */
/* Nada se recorta: el campo se marca y el guardado se detiene hasta que el docente lo acorte. */
.campo textarea.excede, .campo input.excede, input.excede, textarea.excede { border-color: var(--error); box-shadow: 0 0 0 3px var(--error-fondo); }
.excede-nota { display: inline-block; font-size: var(--t-xs); font-weight: 600; color: var(--error); }

/* Material del docente */
.campo textarea.t-material { min-height: 0; height: 52vh; font-size: var(--t-sm); line-height: 1.55; }
.contador { font-size: var(--t-xs); color: var(--tenue); }
.contador.lleno { color: var(--error); font-weight: 600; }
.material-acc { display: flex; align-items: center; gap: var(--e4); flex-wrap: wrap; margin-top: var(--e3); }

/* ── T. RECORRIDO (v0.4.5) ─────────────────────────────────────── */
/* Línea vertical con etapas que se abren en su lugar (113A), capítulos y transiciones (114A). */
.pie-pieza { display: flex; align-items: center; flex-wrap: wrap; gap: var(--e2) var(--e3); margin-top: var(--e3); }
.pie-pieza .nota { margin: 0; font-size: var(--t-xs); max-width: 70ch; }
.nodo.nodo-ext::before { width: 10px; height: 10px; margin-top: -5px; left: -25px; background: var(--superficie3); border-width: 1px; }
.nodo.nodo-fin::before { top: 15px; }
.nodo-ext .nodo-txt .tenue, .nodo-ext .nodo-txt span { font-weight: 400; }
.nodo-ext { margin-bottom: var(--e3); }
.vacio-linea { text-align: left; padding: var(--e3) var(--e4); border: 1px dashed var(--borde2); border-radius: var(--r-md); }
.vacio-linea p { max-width: 70ch; margin: 0; }
.vacio-linea b { color: var(--texto); }
.orden-cab .cod { flex: none; }
.orden-cab .meta .destino { color: var(--tinta-3); font-weight: 600; }
.orden-cab .menu { flex: none; }
.orden-cab .menu-btn { width: 30px; height: 30px; }
.orden-cab .menu-btn svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.chev[aria-expanded="true"] svg { transform: rotate(90deg); }
.chev svg { transition: transform var(--mov-1); }
.asa { border: 0; background: none; padding: 0; border-radius: var(--r-sm); }
.asa:hover, .asa:focus-visible { color: var(--tenue); background: var(--superficie2); }
.orden-cab[draggable="true"] { cursor: pointer; }
.nodo.arrastrando { opacity: .5; }
.nodo.destino-drop > .orden { box-shadow: 0 -3px 0 var(--acento); }
.orden-cap { background: var(--superficie2); }
.orden-cap .orden-tit { font-family: var(--f-titulo); }
.nodo.nodo-cap::before { border-color: var(--relleno); background: var(--relleno); }
.orden-trans { border-style: dashed; box-shadow: none; }
.orden-trans .orden-tit { font-weight: 400; color: var(--texto2); }
.orden-trans:not(.abierto) .orden-cab { min-height: 38px; }
.orden-cuerpo > .pest-int { margin-top: 0; }
.orden-cuerpo .rotulo .btn-ayuda { margin-left: 0; }
.chip svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; vertical-align: -1px; }

/* Ficha pequeña dentro de una etapa: actividad, mensaje, salida, variante. */
.ficha-mini { border: 1px solid var(--borde); border-radius: var(--r-md); padding: var(--e3) var(--e4); margin-bottom: var(--e3); background: var(--superficie); }
.ficha-mini-cab { display: flex; align-items: center; flex-wrap: wrap; gap: var(--e2); margin-bottom: var(--e3); }
.ficha-mini-cab .nombre-final { flex: 1 1 220px; }
.ficha-mini-cab .campo { margin: 0; }
.ficha-mini-cab .casilla { margin: 0; white-space: nowrap; font-size: var(--t-sm); }
.ficha-mini-cab .acc { margin-left: auto; display: flex; gap: var(--e1); }
.ficha-mini-cab > .nota { margin: 0; font-size: var(--t-xs); }
.ficha-mini .bloque { margin-bottom: var(--e3); }
.ficha-mini > .campo:last-child, .ficha-mini > .bloque:last-child { margin-bottom: 0; }
.act-decision { border-left: 3px solid var(--acento); }
.act-accion { border-left: 3px solid var(--borde2); }
.c-med2 select { width: 290px; }

/* Condiciones, requisitos y efectos: renglones como las reglas de los finales. */
.cond { display: flex; align-items: center; flex-wrap: wrap; gap: var(--e2) var(--e3); padding: var(--e2) var(--e3); background: var(--superficie2); border-radius: var(--r-sm); font-size: var(--t-sm); }
.cond .campo { margin: 0; }
.cond > .btn { margin-left: auto; }
.cond .nota { margin: 0; font-size: var(--t-xs); }
.cond-t { font-weight: 600; color: var(--texto2); font-size: var(--t-sm); }
.vals { display: inline-flex; flex-wrap: wrap; gap: var(--e1) var(--e3); }
.vals .casilla, .cond .casilla { margin: 0; }
.efectos { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--e2) var(--e3); align-items: center; }
.ef-cont { display: flex; flex-direction: column; align-items: flex-start; gap: var(--e1); min-width: 0; }
.ef-cont > .cond { align-self: stretch; }
.ef-cont .campo { margin: 0; }
.ef-cont .nota { margin: 0; font-size: var(--t-xs); }
.renglon-cab.r-objeto > span:nth-child(4), .renglon-cab.r-objeto > span:nth-child(5) { text-align: center; }
.ref .x { border: 0; background: none; color: var(--tenue); cursor: pointer; padding: 0 0 0 var(--e1); font-size: var(--t-md); line-height: 1; }
.ref .x:hover { color: var(--error); }

/* Decisión: una opción por valor de la variable; votación en equipos. */
.r-opc { grid-template-columns: 120px minmax(0, 1fr) minmax(0, 1fr); }
.r-opc > .cod { margin-top: var(--e2); }
.opciones-dec { margin-bottom: var(--e3); }
.votacion { background: var(--superficie2); border-radius: var(--r-md); padding: var(--e3) var(--e4) 0; margin-bottom: var(--e3); }
.votacion .rotulo .nota { font-weight: 400; margin: 0; }
.votacion .rotulo { display: block; }
.chips-casillas { display: flex; flex-direction: column; gap: var(--e1); }
.chips-casillas .casilla { margin: 0; font-size: var(--t-sm); align-items: flex-start; }
.ajuste.plazo { box-shadow: none; background: var(--superficie2); border-color: var(--borde); margin-bottom: var(--e3); padding-bottom: var(--e2); }
.ajuste.plazo .fila > .campo { margin-bottom: var(--e2); }

/* Objetos */
.r-objeto { grid-template-columns: 56px minmax(0, .8fr) minmax(0, 1.6fr) 104px 96px 102px; align-items: center; }
.r-objeto > .cod { margin-top: 0; }
.r-objeto > .casilla { margin: 0; justify-self: center; }
.r-objeto .acc { margin-top: 0; }
.solo-angosto { display: none; }
@container area (max-width: 820px) {
    .renglon-cab.r-objeto, .renglon-cab.r-opc { display: none; }
    .r-objeto .campo[data-etq]::before, .r-opc .campo[data-etq]::before {
        content: attr(data-etq); display: block; font-size: var(--t-xs); font-weight: 600; color: var(--texto2); margin-bottom: var(--e1);
    }
    .r-objeto { grid-template-columns: 56px minmax(0, 1fr) 102px; }
    .r-objeto > .campo, .r-objeto > .casilla { grid-column: 2 / 3; justify-self: start; }
    .r-objeto .acc { grid-column: 3; grid-row: 1; }
    .solo-angosto { display: inline; }
    .r-opc { grid-template-columns: 90px minmax(0, 1fr); }
    .r-opc > .campo:last-child { grid-column: 2 / 3; }
}

/* Tiempo */
.barra-tiempo { background: var(--superficie3); }
.total-t { font-size: var(--t-sm); margin: var(--e2) 0; }
#rc-tabla-tiempo { margin-top: var(--e3); }
#rv-tablas h4 { font-size: var(--t-md); color: var(--tinta-2); margin: var(--e4) 0 var(--e2); }
.revision li.e, .revision li.a { color: var(--texto); }
.revision li.e span, .revision li.a span { min-width: 0; }

/* Etapa abierta a lo ancho angosto: la cabecera cede la meta secundaria. */
@container area (max-width: 900px) {
    .orden-cab .meta > span:first-child { display: none; }
}
@container area (max-width: 760px) {
    .orden-cab .meta .reloj-min { display: none; }
    .orden-cuerpo { padding: 0 var(--e3) var(--e3); }
    .c-med2 select { width: 240px; }
}
.rejilla-ed.carga { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.rejilla-ed.carga #rc-tabla-tiempo { margin-top: 0; }
@container area (max-width: 820px) { .rejilla-ed.carga { grid-template-columns: minmax(0, 1fr); } }
@container area (max-width: 620px) {
    .orden-cab .chips { display: none; }
    .orden-cab .asa { display: none; }
}
.menu-panel button:disabled { color: var(--tenue); cursor: default; opacity: .6; }
.menu-panel button:disabled:hover { background: none; }
/* Rótulo con destellos de Gemini (Planteamiento de la etapa). */
.rotulo-gem { display: flex; align-items: center; flex-wrap: wrap; gap: var(--e2) var(--e4); margin-bottom: var(--e3); }
.rotulo-gem .rotulo { margin: 0; }
.campo > .etq .btn-gemini { margin-left: var(--e1); vertical-align: middle; }
.pie-pieza .gemini-txt { margin-left: var(--e2); }

/* ── U. RETOS (v0.4.7) ─────────────────────────────────────────── */
/* Lista por etapa y ficha (125A); opciones de opción múltiple en renglones. */
.ficha-reto .ficha-cab { margin-bottom: var(--e1); }
.ficha-reto > .nota { margin: 0 0 var(--e3); font-size: var(--t-xs); }
.ficha-reto .rotulo .btn-ayuda { margin-left: 0; }
.r-opm { grid-template-columns: 112px minmax(0, 1fr) 102px; align-items: center; row-gap: var(--e2); }
.r-opm > .casilla { margin: 0; font-size: var(--t-sm); }
.r-opm .acc { margin-top: 0; }
.r-opm .r-retro { grid-column: 2 / 3; }
.r-opm .r-retro input { font-size: var(--t-sm); }
.opciones-reto { margin-bottom: var(--e2); }
.aceptadas { max-width: 70ch; }
.ficha-mini-cab .c-ae { flex: 1 1 280px; }
.c-ae select { width: 100%; }
.nota.criterio { margin: 0 0 var(--e3); font-size: var(--t-xs); max-width: 90ch; }
.nota.efectivo { margin: 0 0 var(--e3); }
.lista-ref { margin: 0 0 var(--e2); padding-left: var(--e5); font-size: var(--t-sm); }
.lista-ref li { margin-bottom: var(--e1); }
.rotulo.rotulo-sep { margin-top: var(--e4); }
.fila.arriba { align-items: flex-start; }
.bloque.solucion, .bloque.justificacion, .bloque.reacciones { margin-top: var(--e4); }
.bloque.justificacion > .campo { margin-top: var(--e3); }
.fuente-reto > .chip { justify-self: start; }
.fuente-reto .fuente-desc { font-size: var(--t-sm); min-width: 0; }
.fuente-reto > .nota { margin: 0; font-size: var(--t-xs); white-space: nowrap; }
#rt-rv-tablas h4 { font-size: var(--t-md); color: var(--tinta-2); margin: var(--e4) 0 var(--e2); }
#rt-vacio .palanca { margin-top: var(--e3); }
@container area (max-width: 820px) {
    .r-opm { grid-template-columns: 104px minmax(0, 1fr) 102px; }
    .fuente-reto > .nota { display: none; }
}

/* ── V. TEMA OSCURO DEL PANEL (v0.4.7.1; acuerdos 133A a 136A) ───── */
/* Las mismas variables con otros valores (DT-7: no es un segundo sistema). Marino profundo de la marca;
   turquesa como acento y anillo de foco; oro en la acción principal. Lo impreso y el alumno no cambian. */
:root.oscuro {
    color-scheme: dark;
    --fondo: #060f1c;
    --superficie: #0c1a2c;
    --superficie2: #11233a;
    --superficie3: #182e4b;
    --borde: #1f3655;
    --borde2: #4a6a92;
    --texto: #e6eef8;
    --texto2: #b3c4d9;
    --tenue: #8ba1bc;

    --ok: #57d6ab;        --ok-fondo: #0c2c26;        --ok-borde: #1d5a4a;
    --atencion: #f2bd5c;  --atencion-fondo: #2c2211;  --atencion-borde: #6a5022;
    --error: #ff8f84;     --error-fondo: #361618;     --error-borde: #7a2f2c;
    --info: #72c7ee;      --info-fondo: #0d2840;      --info-borde: #22506f;
    --ok-solido: #0f8a6a; --error-solido: #c0392f;

    --tinta-1: #f1f6fc;
    --tinta-2: #d4e3f3;
    --tinta-3: #6fd3e4;
    --acento: #2bd4d6;
    --relleno: #0d5f8c; --relleno-hover: #1173a8; --sobre-relleno: #fff;
    --cabecera-fondo: rgba(12, 26, 44, .9);
    --toast-fondo: #183a5e; --toast-texto: #eaf2fa;
    --velo: rgba(0, 4, 10, .66);

    --sombra-1: 0 1px 2px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .25);
    --sombra-2: 0 2px 4px rgba(0, 0, 0, .35), 0 8px 20px rgba(0, 0, 0, .35);
    --sombra-3: 0 8px 16px rgba(0, 0, 0, .45), 0 24px 56px rgba(0, 0, 0, .55);
    --sombra: var(--sombra-1);
    --anillo: 0 0 0 3px rgba(19, 220, 218, .42);

    /* Barras laterales: un tono más oscuras que las superficies, para seguir distinguiéndose. */
    --lat-base: #01060e; --lat-color: #020c1c;
    --lat-velo1: rgba(1, 10, 24, .8); --lat-velo2: rgba(1, 8, 20, .96); --lat-transp: rgba(1, 8, 20, 0);
    --lat-brillo: rgba(19, 220, 218, .16); --lat-oro: rgba(226, 163, 58, .12);

    --calor-0: #0f3a2e; --calor-1: #3a3010; --calor-2: #4a2e0c; --calor-2-tinta: #ffc77a;
    --calor-3: #5a2418; --calor-3-tinta: #ffb3a0; --calor-4: #c0392f; --calor-4-tinta: #fff;

    --portada-fondo: #071426; --portada-brillo: rgba(19, 220, 218, .12); --portada-transp: rgba(6, 15, 28, 0);
}
/* El wordmark conserva sus colores de marca: sobre fondo oscuro el marino no se lee (1.3:1), así que
   toma el degradado claro del isotipo (cian → turquesa → azul). */
:root.oscuro .wordmark {
    background: linear-gradient(100deg, var(--cian) 0%, var(--turquesa) 55%, var(--azul) 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
:root.oscuro .campo input[disabled], :root.oscuro .campo textarea[disabled], :root.oscuro .campo select[disabled] { opacity: .75; }
:root.oscuro img.isotipo, :root.oscuro .entrada-marca img { filter: drop-shadow(0 4px 14px rgba(19, 220, 218, .22)); }

/* Botón de tema: luna en claro, sol en oscuro. */
.tema-btn, .tema-ic { display: inline-flex; align-items: center; gap: 6px; }
.tema-btn svg, .tema-ic svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ico-sol { display: none; }
:root.oscuro .ico-sol { display: inline-flex; }
:root.oscuro .ico-luna { display: none; }
.usuario-acc { display: flex; flex-wrap: wrap; gap: var(--e1) var(--e4); }
.tema-ic {
    justify-content: center; width: 40px; height: 40px; margin-top: auto; margin-bottom: var(--e2);
    border: 0; border-radius: var(--r-md); background: none; color: var(--lat-enlace); cursor: pointer;
}
.tema-ic svg { width: 20px; height: 20px; }
.tema-ic + .avatar { margin-top: 0; }

/* ── W. PANTALLA DE ENTRADA DEL DOCENTE (v0.4.7.1) ──────────────── */
/* Dos paneles: el formulario a la izquierda y la portada con el lema a la derecha. Sigue el tema del sistema. */
.btn-bloque { display: flex; width: 100%; justify-content: center; }
.entrada-body { background: var(--fondo); }
.entrada { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 520px) minmax(0, 1fr); }
.entrada-form {
    display: flex; flex-direction: column; justify-content: center;
    padding: var(--e7) var(--e7); background: var(--superficie); border-right: 1px solid var(--borde);
}
.entrada-form > section { width: 100%; max-width: 400px; }
.entrada-marca { display: flex; align-items: center; gap: var(--e3); margin-bottom: var(--e7); }
.entrada-marca img { flex: none; width: 44px; height: 44px; }
.entrada-marca .wordmark { font-size: var(--t-xl); letter-spacing: .24em; }
.ceja { margin: 0 0 var(--e2); font-size: var(--t-xs); font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--tinta-3); }
.entrada-tit { font-size: var(--t-2xl); color: var(--tinta-1); margin: 0 0 var(--e2); }
.entrada-sub { color: var(--texto2); margin: 0 0 var(--e5); }
.entrada-form .campo { margin-bottom: var(--e4); }
.entrada-form .btn-bloque { margin-top: var(--e2); height: 46px; font-size: var(--t-md); }
.entrada-pie { margin: var(--e4) 0 0; text-align: center; }
.entrada-nota { margin: var(--e7) 0 0; font-size: var(--t-xs); color: var(--tenue); }
.entrada-arte {
    position: relative; overflow: hidden; display: flex; align-items: center;
    padding: var(--e7) clamp(var(--e6), 7vw, 120px);
    background:
        radial-gradient(70% 60% at 22% 18%, var(--portada-brillo) 0%, var(--portada-transp) 60%),
        radial-gradient(60% 55% at 85% 95%, var(--lat-oro) 0%, var(--portada-transp) 62%),
        linear-gradient(160deg, var(--portada-fondo) 0%, var(--fondo) 70%);
}
.entrada-arte::after {
    content: ''; position: absolute; right: -90px; bottom: -110px; width: 520px; height: 520px;
    background: url('../img/isotipo.png') center / contain no-repeat; opacity: .07; pointer-events: none;
}
.entrada-arte-int { position: relative; z-index: 1; width: 100%; max-width: 760px; }
.entrada-arte-int .ceja { margin-bottom: var(--e4); }
.entrada-lema {
    margin: 0; font-family: var(--f-titulo); font-size: var(--t-portada); font-weight: 500; line-height: 1.12;
    letter-spacing: -.01em; color: var(--tinta-2); max-width: 15ch;
}
:root.oscuro .entrada-lema { color: var(--texto2); }
@media (max-width: 900px) {
    .entrada { grid-template-columns: minmax(0, 1fr); }
    .entrada-arte { display: none; }
    .entrada-form { border-right: 0; padding: var(--e6) var(--e5); align-items: center; }
    .entrada-form > section, .entrada-marca, .entrada-nota { width: 100%; max-width: 400px; }
}

/* ── X. GEMINI EN RETOS (v0.4.8) ────────────────────────────────── */
.rotulo > .der { margin-left: auto; }
.ficha-reto .ficha-cab .der { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--e1) var(--e3); }
.pie-pieza .gemini-txt { margin-left: auto; }
#rt-lote { display: flex; width: 100%; margin-top: var(--e1); }
#rt-lote:disabled { color: var(--tenue); cursor: default; }
#rt-lote:disabled svg { fill: var(--tenue); }
.por-revisar { display: inline-flex; margin-right: var(--e1); }
.por-revisar svg { width: 13px; height: 13px; fill: var(--info); }
.aviso-gemini {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--e2) var(--e4);
    background: var(--info-fondo); color: var(--info); border-color: var(--info-borde); margin: 0 0 var(--e3);
}
.aviso-gemini > span { display: inline-flex; align-items: center; gap: var(--e2); }
.aviso-gemini svg { width: 15px; height: 15px; flex: none; fill: currentColor; }
.lote-lista { list-style: none; margin: 0 0 var(--e4); padding: 0; max-height: 55vh; overflow-y: auto; }
.lote-lista > li { padding: var(--e2) 0; border-bottom: 1px solid var(--borde); font-size: var(--t-sm); }
.lote-edo { float: right; font-size: var(--t-xs); color: var(--tenue); }
.lote-trabajando .lote-edo { color: var(--info); font-weight: 600; }
.lote-ok .lote-edo { color: var(--ok); font-weight: 600; }
.lote-error .lote-edo { color: var(--error); font-weight: 600; }
.lote-det ul { margin: var(--e1) 0 0; padding-left: var(--e5); color: var(--texto2); font-size: var(--t-xs); }
.lote-det .err { margin: var(--e1) 0 0; font-size: var(--t-xs); color: var(--error); }
#rt-lote:not(:disabled) { color: var(--info); }
#rt-lote { text-align: left; }

/* ── Y. MENSAJES DE REVISIÓN EN LENGUAJE LLANO (v0.4.9, 137A) ───── */
.revision .rv-que { display: block; }
.revision .rv-hacer { display: block; margin-top: 3px; color: var(--texto2); }
.revision .rv-hacer b { color: var(--tinta-2); font-weight: 600; }

/* ── Z. AYUDAS (v0.5.0; acuerdos 139A a 151A) ───────────────────── */
/* Política: casilla con un número en la misma línea («Tras [2] errores seguidos»). */
.fila-casilla { display: flex; align-items: center; flex-wrap: wrap; gap: var(--e2); margin: 0 0 var(--e2); font-size: var(--t-sm); color: var(--texto2); }
.fila-casilla .casilla { margin: 0; }
.fila-casilla input[type="number"] { width: 64px; }
.fila-casilla i { font-style: normal; }
.ajuste [data-si-pol] { margin-top: var(--e3); }
.ajuste > .palanca { margin-bottom: var(--e3); }
/* Lista: número de pistas del reto. */
.n-pistas { display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pil); background: var(--superficie3); font-size: 11px; font-weight: 600; color: var(--texto2); }
/* Consigna y solución del reto, a la vista para no revelarla. */
.reto-ref { border: 1px solid var(--borde); border-radius: var(--r-md); background: var(--superficie2); padding: var(--e2) var(--e3); margin: 0 0 var(--e4); font-size: var(--t-sm); }
.reto-ref > summary { cursor: pointer; font-weight: 600; color: var(--tinta-2); }
.reto-ref[open] > summary { margin-bottom: var(--e2); }
.reto-ref p { margin: 0 0 var(--e2); max-width: 70ch; }
.reto-ref .nota { font-size: var(--t-xs); margin: 0; }
.ajustes-reto .fila { align-items: flex-end; }
.ajustes-reto .fila > .palanca { margin-bottom: 18px; }
.ajustes-reto .efectivo { margin: 0; font-size: var(--t-xs); }
/* Escalera: un escalón por grado; las pistas son piezas que se abren en su lugar. */
.ficha-ayudas .escalera { margin-top: var(--e4); }
.escalon-cab { display: flex; flex-direction: column; gap: var(--e1); padding: var(--e3) 0 var(--e2); }
.escalon-cab b { font-size: var(--t-md); color: var(--tinta-2); display: flex; align-items: center; gap: var(--e1); }
.escalon-cab .nota { margin: 0; font-size: var(--t-xs); max-width: 80ch; }
.escalon .orden { margin-bottom: var(--e2); }
.escalon .pie-pieza { margin-top: 0; }
.escalon.inactivo .escalon-cab b { color: var(--texto2); }
.escalon-fin .marca-e { border-style: dashed; }
.escalon-fin.activo .marca-e { border-style: solid; }
.orden-pista .orden-cab { padding-left: var(--e2); }
.escalon .orden-pista .orden-tit { flex: 1 1 auto; min-width: 4em; font-weight: 400; }
.orden-pista .orden-tit.tenue { color: var(--tenue); font-style: italic; }
.orden-pista .orden-cab .chips { margin-left: auto; flex: none; }
.orden-pista .orden-cuerpo { padding-left: var(--e4); }
.orden-pista .orden-cuerpo > .rotulo .btn-ayuda { margin-left: 0; }
.orden-pista .pie-pieza { justify-content: flex-start; }
/* Retos: la pista dirigida de cada respuesta prevista (147A), de solo lectura. */
.pista-dirigida { margin: var(--e2) 0 0; font-size: var(--t-xs); }
@container area (max-width: 760px) {
    .orden-pista .orden-cab .chips .chip-liso { display: none; }
}
.md-lista .gemini-txt.md-pie { text-align: left; }

/* ── AA. SEGUIMIENTO Y CIERRE (v0.5.2; acuerdos 152A a 166A) ───────── */
/* Cómo se juega: flujo de pasos y duración estimada (154A, 161A). */
.sc-turnos { margin-bottom: var(--e4); }
.sc-turnos .t { margin-bottom: var(--e2); }
.sc-flujo { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2); }
.sc-flujo > svg { width: 16px; height: 16px; fill: none; stroke: var(--tenue); stroke-width: 1.8; flex: none; }
.sc-paso { display: flex; flex-direction: column; gap: var(--e1); padding: var(--e2) var(--e3); border: 1px solid var(--borde); border-radius: var(--r-md); background: var(--superficie2); }
.sc-paso .rotulo { margin: 0; font-size: var(--t-xs); }
.sc-paso .chips { display: flex; flex-wrap: wrap; gap: var(--e1); }
.sc-paso.sc-turno { border-color: var(--info-borde); background: var(--info-fondo); }
.sc-dur { margin: var(--e3) 0 0; }
.sc-dur.excede b { color: var(--atencion); }
/* Lista: agregar actividad por tipo. */
.sc-agregar { display: flex; align-items: center; gap: var(--e2); }
.sc-agregar .campo { margin: 0; flex: 1 1 9em; min-width: 8em; }
.sc-agregar select { width: 100%; }
.md-lista .sc-agregar .btn { flex: none; width: auto; }
/* Ficha: filas de opciones, previstas, aprendizajes y preguntas. */
.ficha-cierre .bloque { margin-top: var(--e4); }
.ficha-cierre .bloque > .palanca { margin: var(--e2) 0; }
.fila-opcion { align-items: flex-end; }
.fila-opcion > .cod { flex: none; align-self: center; min-width: 1.6em; font-weight: 600; color: var(--tinta-3); }
.fila-opcion > .casilla { margin-bottom: 18px; flex: none; }
.fila-opcion > .btn { margin-bottom: 14px; flex: none; }
.ficha-cierre .pie-pieza { justify-content: flex-start; align-items: center; flex-wrap: wrap; gap: var(--e2); }
.ficha-cierre .pie-pieza .nota { margin: 0; font-size: var(--t-xs); }
/* Valoración y entrega. */
.sc-val td { vertical-align: top; }
.sc-val .campo { margin: 0; min-width: 14em; }
.sc-val .fila { margin-top: var(--e2); }
.sc-val .palanca, .sc-val .casilla { margin: 0; }
/* Revisión: AE sin evidencia individual. */
.tabla tr.fila-falta td { background: var(--atencion-fondo); }
@container area (max-width: 760px) {
    .sc-flujo > svg { display: none; }
    .sc-paso { flex: 1 1 100%; }
}
.tabla td.sc-tipo { white-space: nowrap; }

/* ── AB. DISEÑO VISUAL (v0.5.4; acuerdos 167A a 183A) ───────────── */
/* Miniaturas: lista de medios, superficies y la miniatura de solo lectura de los demás componentes (171A). */
.dv-thumb {
    display: grid; place-items: center; flex: none; width: 32px; height: 24px; overflow: hidden;
    border-radius: var(--r-sm); background: var(--superficie3); color: var(--tenue);
}
.dv-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dv-thumb svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.md-fila.dv-fila { grid-template-columns: auto minmax(0, 1fr) auto; }
.md-fila.dv-fila .txt .codigo { margin-right: var(--e1); }
.dv-acciones { display: flex; align-items: center; flex-wrap: wrap; gap: var(--e2) var(--e4); margin-bottom: var(--e4); }
.dv-nuevo { display: flex; align-items: center; gap: var(--e2); }
.dv-nuevo .campo { margin: 0; width: 13em; }
.dv-nuevo select { width: 100%; }
.dv-nuevo .btn { flex: none; }
/* Espacio usado (acuerdo 181). */
.dv-espacio { display: flex; flex-direction: column; gap: var(--e1); margin-left: auto; min-width: 11em; font-size: var(--t-xs); color: var(--tenue); }
.dv-barra { display: block; height: 6px; border-radius: var(--r-pil); background: var(--superficie3); overflow: hidden; }
.dv-barra i { display: block; height: 100%; width: 0; background: var(--acento); border-radius: var(--r-pil); }
.dv-barra.llena i { background: var(--atencion); }
.dv-vacia { max-width: 70ch; }
.dv-vacia p { color: var(--texto2); }
/* Ficha: archivo a la izquierda, datos a la derecha; se apilan en área angosta. */
.ficha-medio .ficha-cab { flex-wrap: wrap; }
.ficha-medio .ficha-cab > div:first-child { flex: 1 1 16em; min-width: 0; }
.ficha-medio .ficha-cab .der { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--e1) var(--e3); }
.dv-ficha-rej { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 1.5fr); gap: var(--e5); align-items: start; margin-bottom: var(--e4); }
.dv-archivo .rotulo { margin-bottom: var(--e2); }
.dv-vista {
    display: grid; place-items: center; aspect-ratio: 16 / 9; overflow: hidden;
    border: 1px solid var(--borde); border-radius: var(--r-md); background: var(--superficie2);
}
.dv-vista img { width: 100%; height: 100%; object-fit: contain; display: block; }
.dv-vista.sin {
    border-style: dashed; border-color: var(--borde2); padding: var(--e4); gap: var(--e1); align-content: center;
    text-align: center; font-size: var(--t-sm); color: var(--texto2);
}
.dv-vista.sin .nota { font-size: var(--t-xs); margin: 0; }
.dv-vista-ic svg { width: 34px; height: 34px; fill: none; stroke: var(--borde2); stroke-width: 1.4; }
.dv-vista.soltando { border-color: var(--acento); background: var(--info-fondo); }
.dv-meta { font-size: var(--t-xs); margin: var(--e2) 0 0; }
.dv-archivo .pie-pieza { margin-top: var(--e2); justify-content: flex-start; }
.dv-archivo .pie-pieza .btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; margin-right: var(--e1); }
.dv-revisado { margin-top: var(--e3); }
.dv-revisado-nota { font-size: var(--t-xs); margin: var(--e1) 0 0; }
.dv-campos .fila { margin-top: 0; }
.dv-encargo .fila { align-items: flex-end; }
.dv-encargo .fila > .btn { margin-bottom: 14px; flex: none; }
.dv-encargo .fila > .btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; margin-right: var(--e1); }
@container area (max-width: 820px) {
    .dv-ficha-rej { grid-template-columns: minmax(0, 1fr); gap: var(--e3); }
    .dv-vista { max-width: 420px; }
}
/* Superficies: grupos plegables y un renglón por pieza. */
.dv-grupo { border: 1px solid var(--borde); border-radius: var(--r-md); margin-top: var(--e3); background: var(--superficie); }
.dv-grupo > summary { display: flex; align-items: center; gap: var(--e3); padding: var(--e2) var(--e3); cursor: pointer; color: var(--tinta-2); }
.dv-grupo > summary .nota { margin: 0; font-size: var(--t-xs); }
.dv-grupo[open] > summary { border-bottom: 1px solid var(--borde); }
.dv-sup-lista { padding: var(--e1) var(--e2); }
.dv-sup-fila {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(12em, 18em) minmax(7.5em, auto);
    align-items: center; gap: var(--e3); padding: var(--e1) var(--e2); border-radius: var(--r-sm); font-size: var(--t-sm);
}
.dv-sup-fila + .dv-sup-fila { border-top: 1px solid var(--borde); }
.dv-sup-fila.pendiente { background: var(--atencion-fondo); }
.dv-sup-tit { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dv-sup-tit .cod { margin-right: var(--e1); }
.dv-sup-chips { display: flex; gap: var(--e1); }
.dv-sup-fila .campo { margin: 0; }
.dv-sup-fila select { width: 100%; }
.dv-sup-acc { justify-self: end; }
@container area (max-width: 900px) {
    .dv-sup-fila { grid-template-columns: auto minmax(0, 1fr) minmax(10em, 15em); }
    .dv-sup-chips, .dv-sup-acc { display: none; }
}
@container area (max-width: 620px) {
    .dv-sup-fila { grid-template-columns: auto minmax(0, 1fr); }
    .dv-sup-fila .campo { grid-column: 1 / -1; }
}
/* Miniatura de solo lectura en Historia, Recorrido y Retos. */
.dv-mini { display: flex; flex-direction: column; gap: var(--e1); margin: 0 0 var(--e3); font-size: var(--t-sm); }
.dv-mini .etq { font-size: var(--t-sm); font-weight: 600; color: var(--texto2); }
.dv-mini-cuerpo { display: flex; align-items: center; gap: var(--e3); }
.dv-mini-cuerpo img, .dv-mini-sin {
    width: 96px; height: 54px; flex: none; object-fit: cover; border-radius: var(--r-sm);
    border: 1px solid var(--borde); background: var(--superficie2);
}
.dv-mini-sin { display: grid; place-items: center; color: var(--tenue); }
.dv-mini-sin svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.dv-mini-cuerpo > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dv-mini .nota { margin: 0; font-size: var(--t-xs); }
.dv-mini-vacia { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: var(--e1) var(--e2); }
.dv-mini-vacia .etq { flex-basis: 100%; }
.dv-archivo .pie-pieza .btn + .btn { margin-left: 0; }

/* ── AC. DISEÑO VISUAL: TEMA Y SUPERFICIES (v0.5.5; acuerdos 172A y 177A a 180A) ── */
/* Punto de interés en la ficha del medio. */
.dv-vista.con-foco { position: relative; cursor: crosshair; }
.dv-foco-pt {
    position: absolute; width: 22px; height: 22px; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none;
    border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, .65), inset 0 0 0 4px rgba(0, 0, 0, .35);
}
.dv-foco-pt::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: #fff; }
.dv-foco { margin-top: var(--e4); }
.dv-foco .rotulo { margin-bottom: var(--e1); }
.dv-foco .nota { font-size: var(--t-xs); margin: 0 0 var(--e2); }
.dv-foco .pie-pieza { justify-content: flex-start; flex-wrap: wrap; gap: var(--e2); }
.dv-foco .pie-pieza .btn + .gemini-txt { margin-left: 0; }
/* Superficies: miniatura heredada y plantilla elegible. */
.dv-thumb.heredado { outline: 1px dashed var(--borde2); outline-offset: -1px; }
.dv-thumb.heredado img { opacity: .55; }
.dv-sup-chips { align-items: center; }
.dv-sup-chips .dv-pk { width: 8.5em; padding-top: 2px; padding-bottom: 2px; font-size: var(--t-xs); }
.dv-sup-acc { display: flex; align-items: center; gap: var(--e3); }
/* Tema: colores y fuentes lado a lado; se apilan en área angosta. */
.dv-tema-rej { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--e4); align-items: start; }
.dv-tema-rej > .card { margin: 0; }
@container area (max-width: 860px) { .dv-tema-rej { grid-template-columns: minmax(0, 1fr); } }
.dv-preset { margin: 0; width: 13.5em; }
.dv-preset select { width: 100%; }
.dv-color { display: grid; grid-template-columns: 44px minmax(0, 1fr) 7.2em; align-items: center; gap: var(--e3); padding: var(--e2) 0; border-bottom: 1px solid var(--borde); }
.dv-color:last-child { border-bottom: 0; }
.dv-color input[type="color"] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--borde2); border-radius: var(--r-sm); background: var(--superficie); cursor: pointer; }
.dv-color-txt { display: flex; flex-direction: column; min-width: 0; }
.dv-color-txt b { font-size: var(--t-sm); }
.dv-color-txt small { font-size: var(--t-xs); color: var(--texto2); }
.dv-color .campo { margin: 0; }
.dv-hex { font-family: var(--f-mono); font-size: var(--t-sm); width: 100%; }
.dv-con-rot { margin: var(--e4) 0 var(--e2); }
.dv-contrastes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.dv-con { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto auto; align-items: center; gap: var(--e3); font-size: var(--t-sm); padding: 3px 0; }
.dv-con-par { display: grid; place-items: center; height: 24px; border-radius: var(--r-sm); font-weight: 700; font-size: 13px; border: 1px solid rgba(127, 127, 127, .35); }
.dv-con-r { font-variant-numeric: tabular-nums; color: var(--texto2); }
.dv-con-err > span:nth-child(2) { font-weight: 600; }
.dv-f-muestra { margin: calc(-1 * var(--e2)) 0 var(--e4); padding: var(--e3); border: 1px solid var(--borde); border-radius: var(--r-md); background: var(--superficie2); font-size: 17px; line-height: 1.5; overflow-wrap: anywhere; }
.dv-f-muestra.dv-f-tit { font-size: 26px; line-height: 1.2; }
/* Plantillas y fondos por personaje: una fila por plantilla. */
.dv-pl-fila { display: grid; grid-template-columns: minmax(13em, 1.5fr) minmax(11em, 1.2fr) 11.5em 8.5em 5.5em; align-items: center; gap: var(--e3); padding: var(--e2) 0; border-bottom: 1px solid var(--borde); }
.dv-pl-fila:last-child { border-bottom: 0; }
.dv-pl-fila .campo { margin: 0; }
.dv-pl-fila select { width: 100%; }
.dv-pl-cab { font-size: var(--t-xs); color: var(--tenue); font-weight: 600; padding-top: 0; }
.dv-pl-nom { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--e2); min-width: 0; }
.dv-pl-nom small { flex-basis: 100%; font-size: var(--t-xs); color: var(--texto2); }
.dv-per-fila { grid-template-columns: minmax(13em, 1.5fr) minmax(11em, 1.2fr) 5.5em; }
@container area (max-width: 900px) {
    .dv-pl-fila { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }
    .dv-pl-fila .dv-pl-nom { grid-column: 1 / -1; }
    .dv-pl-fila > span:last-child { grid-column: 1 / -1; }
    .dv-pl-cab { display: none; }
    .dv-per-fila { grid-template-columns: minmax(0, 1fr) auto; }
}
/* Muestra: el lienzo del jugador a tamaño real, escalado para caber (179A). */
.dv-m-sel { margin: 0; width: 20em; max-width: 60vw; }
.dv-m-sel select { width: 100%; }
.dv-m-barra { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e2) var(--e4); margin-bottom: var(--e3); }
.dv-m-barra .chip.actual { outline: 2px solid var(--acento); outline-offset: 1px; }
.dv-m-marco { position: relative; overflow: hidden; border: 1px solid var(--borde); border-radius: var(--r-md); background: #000; }
.dv-lienzo {
    position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden;
    background: var(--er-fondo); color: var(--er-texto); font-family: var(--er-lec);
}
.dv-l-pantalla { position: absolute; inset: 0; }
.dv-l-velo-fondo { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, .45), rgba(0, 0, 0, .65)); }
.dv-l-caja { position: absolute; left: 0; top: 0; overflow: hidden; }
.dv-l-caja.ventana { background: var(--er-sup); border: 1px solid var(--er-borde); border-radius: 12px; box-shadow: 0 24px 60px rgba(0, 0, 0, .45); }
.dv-l-img { position: absolute; max-width: none; display: block; }
.dv-l-capa { position: absolute; inset: 0; pointer-events: none; }
.dv-l-barra {
    position: absolute; left: 0; right: 0; top: 0; height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 18px;
    background: var(--er-sup); border-bottom: 1px solid var(--er-borde); font-size: 15px;
}
.dv-l-obj { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dv-l-obj::before { content: 'Objetivo: '; color: var(--er-acento); font-weight: 700; }
.dv-l-ic { border: 1px solid var(--er-borde); border-radius: 6px; padding: 4px 10px; font-size: 14px; }
.dv-l-cont { position: absolute; overflow: auto; display: flex; flex-direction: column; gap: 14px; padding: 22px 26px; box-sizing: border-box; }
.dv-l-cont.placa { border: 1px solid var(--er-borde); border-radius: 12px; }
.dv-l-kick { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--er-acento); }
.dv-l-tit { margin: 0; font-family: var(--er-tit); font-weight: var(--er-peso-tit); font-size: var(--er-t-tit); line-height: 1.15; color: var(--er-acento); }
.dv-l-txt { margin: 0; font-size: var(--er-t-txt); line-height: 1.5; white-space: pre-line; }
.dv-l-acc { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.dv-l-btn { display: inline-block; padding: 10px 20px; border-radius: 8px; background: var(--er-acento); color: var(--er-boton); font-weight: 700; font-size: 16px; }
.dv-l-btn.sec { background: transparent; color: var(--er-texto); border: 1px solid var(--er-borde); }
.dv-l-quien { display: flex; align-items: center; gap: 12px; }
.dv-l-retrato { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; border: 2px solid var(--er-acento); flex: none; }
.dv-l-retrato.ini { display: grid; place-items: center; background: var(--er-acento); color: var(--er-boton); font-family: var(--er-tit); font-weight: 700; font-size: 26px; }
.dv-l-nom { font-family: var(--er-tit); font-weight: var(--er-peso-tit); font-size: 21px; color: var(--er-acento); }
.dv-l-pieza { display: block; align-self: center; max-width: 100%; max-height: 260px; object-fit: contain; }
.dv-l-objeto { display: block; align-self: center; width: 150px; height: 150px; object-fit: contain; }
.dv-l-pieza.vacia, .dv-l-objeto.vacia { display: grid; place-items: center; min-height: 110px; width: 100%; border: 1px dashed var(--er-borde); border-radius: 8px; font-size: 14px; opacity: .8; }
.dv-l-ops { display: flex; flex-wrap: wrap; gap: 10px; }
.dv-l-op { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 1px solid var(--er-acento); border-radius: 8px; font-size: 16px; }
.dv-l-op img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.dv-pk-terminal .dv-l-cont { border: 1px solid var(--er-acento); border-radius: 0; }
.dv-pk-terminal .dv-l-tit { text-transform: uppercase; letter-spacing: .04em; }
.dv-pk-desenlace .dv-l-tit { font-size: calc(var(--er-t-tit) * 1.25); }
/* Repertorio de fuentes (superadmin). */
.fu-lista { display: flex; flex-direction: column; }
.fu-fila { display: grid; grid-template-columns: minmax(14em, 1fr) minmax(0, 1.3fr); gap: var(--e4); padding: var(--e4) 0; border-bottom: 1px solid var(--borde); }
.fu-fila:last-child { border-bottom: 0; }
.fu-muestra b { display: block; font-size: 26px; line-height: 1.2; font-weight: 700; margin-bottom: var(--e1); }
.fu-muestra span { display: block; font-size: 16px; line-height: 1.45; color: var(--texto2); }
.fu-datos .nota { margin: var(--e1) 0; font-size: var(--t-xs); }
.fu-archivos { list-style: none; margin: var(--e2) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--e1) var(--e4); font-size: var(--t-sm); }
.fu-archivos li { display: flex; gap: var(--e2); align-items: baseline; }
.fu-meta { margin-top: var(--e3); align-items: flex-end; }
.fu-meta .btn { margin-bottom: 14px; }
@media (max-width: 760px) { .fu-fila { grid-template-columns: minmax(0, 1fr); } }

/* ═══════════════════════════════════════════════════════════════════
   19. DOCUMENTO IMPRIMIBLE (v0.5.6, acuerdos 23A y 184A a 188A).
   Hoja clara con cualquier tema del panel (D-84). En pantalla, una hoja sobre
   fondo gris con la barra de casillas arriba; al imprimir, página con nombre
   propio («documento»): tamaño del diálogo, márgenes de 15 mm, encabezado con
   el nombre y si lleva soluciones (--doc-cab, lo pone documento.js) y número
   de página. Las casillas agregan clases «sin-…» a <body> y aquí se ocultan
   las piezas con «x-…», «d-sol» y «d-mat».
   ═══════════════════════════════════════════════════════════════════ */
:root {
    --doc-ancho: 816px;          /* ancho de una hoja carta a 96 ppp */
    --doc-etq: 30%;              /* columna de los rótulos */
    --doc-img: 150px;            /* miniatura junto a una pieza */
    --doc-img-chica: 96px;
    --doc-img-grande: 240px;
}
.hoja-doc { background: var(--superficie3); }
.doc-barra { position: sticky; top: 0; z-index: 20; background: var(--cabecera-fondo); backdrop-filter: blur(8px); border-bottom: 1px solid var(--borde); }
.doc-barra-int { max-width: var(--contenido-max); margin: 0 auto; padding: var(--e2) var(--e4); display: flex; flex-direction: column; gap: var(--e1); }
.doc-barra-casillas { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e1) var(--e5); }
.doc-barra-cab { display: flex; align-items: center; gap: var(--e3); flex-wrap: wrap; }
.doc-barra-tit { flex: 1 1 12rem; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.doc-barra-tit b { font-family: var(--f-titulo); color: var(--tinta-1); font-size: var(--t-lg); }
.doc-barra-tit span { color: var(--tenue); font-size: var(--t-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-casillas { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--e1) var(--e4); }
.doc-casillas legend { float: left; padding: 0; margin-right: var(--e1); font-size: var(--t-xs); font-weight: 600; color: var(--texto2); text-transform: uppercase; letter-spacing: .06em; }
.doc-casillas .casilla { margin: 0; font-size: var(--t-sm); }
.doc-casillas .casilla input { width: 16px; height: 16px; }
.doc-casillas .casilla input:disabled + span { color: var(--tenue); }
.doc-barra .nota { margin: 0; font-size: var(--t-xs); }
.doc-barra .nota-error { color: var(--error); }
.doc-hoja {
    max-width: var(--doc-ancho); margin: var(--e5) auto var(--e7); padding: var(--e7);
    background: var(--imp-fondo); box-shadow: var(--sombra-2); border-radius: var(--r-sm);
    font-size: var(--t-sm); line-height: 1.5; color: var(--texto); counter-reset: dsec;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
@media (max-width: 860px) { .doc-hoja { margin: var(--e3) var(--e2) var(--e6); padding: var(--e5) var(--e4); } }

/* Casillas (184A): lo apagado no se muestra ni se imprime. */
.sin-ap .x-ap, .sin-hi .x-hi, .sin-rc .x-rc, .sin-rt .x-rt, .sin-ay .x-ay, .sin-sc .x-sc, .sin-dv .x-dv,
.sin-sol .d-sol, .sin-mat .d-mat, .sin-sol .d-aviso-sol,
.sin-rc.sin-rt.sin-ay .d-sec-rc, .sin-rc.sin-rt.sin-ay .d-ind-rc,
.sin-rt.sin-ay.sin-ap .d-anexo-a, .sin-rt.sin-ay.sin-ap .d-ind-a { display: none !important; }
.d-aviso-nosol, .d-nota-mat { display: none; }
.sin-sol .d-aviso-nosol { display: block; }
.hoja-doc:not(.sin-mat) .d-nota-mat { display: block; }

/* Texto */
.doc-hoja p { margin: 0 0 var(--e2); }
.doc-hoja p:last-child { margin-bottom: 0; }
.d-tenue { color: var(--tenue); }
.d-nota { color: var(--tenue); font-size: var(--t-xs); margin: 0 0 var(--e2); }
.d-ul { margin: 0; padding-left: 1.15rem; }
.d-ul li { margin-bottom: 2px; }
.d-lead { font-size: var(--t-md); font-weight: 600; color: var(--tinta-1); margin: 0 0 var(--e2); }
.d-num { text-align: right; font-variant-numeric: tabular-nums; }
.d-centro { text-align: center; }

/* Portada y estado */
.d-marca { display: flex; align-items: center; gap: var(--e2); }
.d-marca b { display: block; font-family: var(--f-titulo); font-size: var(--t-lg); letter-spacing: .16em; color: var(--tinta-1); line-height: 1.1; }
.d-marca small { display: block; font-size: var(--t-xs); color: var(--tenue); }
.d-sobre { margin: var(--e7) 0 var(--e1) !important; font-size: var(--t-xs); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--tinta-3); }
.d-portada h1 { font-size: var(--t-2xl); margin: 0 0 var(--e1); }
.d-subt { font-size: var(--t-lg); color: var(--texto2); }
.d-dl.d-ficha { margin-top: var(--e5); border-top: 2px solid var(--azul); }
.d-aviso { margin: var(--e4) 0 !important; padding: var(--e2) var(--e3); border-left: 4px solid var(--atencion); background: var(--atencion-fondo); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.d-aviso-nosol { border-left-color: var(--info); background: var(--info-fondo); }
.d-estado { margin-top: var(--e6); }
.d-h-est { font-size: var(--t-lg); color: var(--tinta-1); margin: 0 0 var(--e2); }
.d-listo { font-weight: 600; color: var(--error); }
.d-listo-ok { color: var(--ok); }
.d-bloq h4 { font-size: var(--t-sm); margin: var(--e3) 0 var(--e1); color: var(--tinta-2); }
.d-bloq li { font-size: var(--t-xs); }
.d-indice { margin-top: var(--e6); }
.d-indice ol { margin: 0 0 var(--e1); padding-left: 1.4rem; }
.d-anexos { list-style: none; padding-left: 0; }

/* Secciones y títulos: el número sale de un contador, así lo apagado no deja huecos. */
.d-sec { margin-top: var(--e7); counter-increment: dsec; }
.d-h2 { font-size: var(--t-xl); color: var(--tinta-1); margin: 0 0 var(--e4); padding-bottom: var(--e2); border-bottom: 2px solid var(--azul); }
.d-sec:not(.d-anexo) > .d-h2::before { content: counter(dsec) '. '; color: var(--tinta-3); }
.d-h3 { font-size: var(--t-lg); color: var(--tinta-2); margin: var(--e5) 0 var(--e2); }
.d-h4 { font-size: var(--t-md); color: var(--tinta-2); margin: var(--e4) 0 var(--e2); }
.d-h5 { font-family: var(--f-texto); font-size: var(--t-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--tinta-3); margin: var(--e3) 0 var(--e1); }
.d-pt { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e1) var(--e2); margin: 0 0 var(--e2); font-size: var(--t-md); color: var(--tinta-1); }
h3.d-pt { font-size: var(--t-lg); }
h5.d-pt { font-family: var(--f-texto); font-size: var(--t-sm); }
.d-chips { display: inline-flex; flex-wrap: wrap; gap: var(--e1); }
.d-cod {
    display: inline-block; padding: 0 var(--e1); border-radius: var(--r-sm); white-space: nowrap;
    font-family: var(--f-mono); font-size: var(--t-xs); font-weight: 600; line-height: 1.6; letter-spacing: 0;
    color: var(--tinta-3); background: var(--imp-caja); border: 1px solid var(--imp-caja-borde);
}
.d-chip {
    display: inline-block; padding: 0 var(--e2); border-radius: var(--r-pil); white-space: nowrap;
    font-family: var(--f-texto); font-size: var(--t-xs); font-weight: 600; line-height: 1.6; letter-spacing: 0;
    color: var(--texto2); background: var(--superficie2); border: 1px solid var(--borde);
}
.d-chip-ok, .d-correcta { color: var(--ok); background: var(--ok-fondo); border-color: var(--ok-borde); }
.d-chip-pend { color: var(--atencion); background: var(--atencion-fondo); border-color: var(--atencion-borde); }
.d-chip-err { color: var(--error); background: var(--error-fondo); border-color: var(--error-borde); }
.d-chip-info { color: var(--info); background: var(--info-fondo); border-color: var(--info-borde); }
.d-chip-vacio { color: var(--tenue); background: var(--imp-fondo); }
.d-correcta { display: inline-block; padding: 0 var(--e2); border: 1px solid; border-radius: var(--r-pil); font-size: var(--t-xs); font-weight: 600; }
.d-solo {
    display: block; width: fit-content; margin-top: 2px; padding: 0 var(--e1); border-radius: var(--r-sm);
    font-family: var(--f-texto); font-size: var(--t-xs); font-weight: 600; letter-spacing: 0; text-transform: none;
    color: var(--info); border: 1px solid var(--info-borde); background: var(--info-fondo);
}
.d-h3 .d-solo, .d-h4 .d-solo { display: inline-block; vertical-align: middle; margin: 0 0 0 var(--e2); }
.d-h5 .d-chip { text-transform: none; vertical-align: middle; margin-left: var(--e1); }

/* Rótulo y valor (187A: solo lo lleno) */
.d-dl { margin: 0 0 var(--e3); border-top: 1px solid var(--borde); }
.d-f { display: grid; grid-template-columns: minmax(0, var(--doc-etq)) minmax(0, 1fr); gap: var(--e3); padding: var(--e2) 0; border-bottom: 1px solid var(--borde); }
.d-f dt { font-size: var(--t-xs); font-weight: 600; color: var(--texto2); }
.d-f dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.d-dl-chica { border-top: 0; margin: var(--e1) 0 0; }
.d-dl-chica .d-f { padding: var(--e1) 0; border-bottom: 0; }

/* Piezas */
.d-pieza, .d-medio { margin: 0 0 var(--e3); padding: var(--e3) var(--e4); border: 1px solid var(--borde); border-radius: var(--r-md); }
.d-cap { margin: var(--e6) 0 0; padding: var(--e3) var(--e4); background: var(--imp-caja); border-radius: var(--r-md); }
.d-etapa { margin-top: var(--e6); padding-top: var(--e3); border-top: 3px solid var(--tinta-3); }
.d-msg { margin: var(--e2) 0; padding: var(--e1) 0 var(--e1) var(--e3); border-left: 3px solid var(--borde2); }
.d-msg-cab { margin-bottom: 2px !important; }
.d-act, .d-reto { margin: var(--e4) 0; padding: var(--e3) var(--e4); border: 1px solid var(--borde2); border-left: 4px solid var(--borde2); border-radius: var(--r-md); }
.d-reto { border-left-color: var(--azul); }
.d-mat-reto { margin: var(--e2) 0 var(--e3); padding: var(--e2) var(--e3); background: var(--superficie2); border-radius: var(--r-sm); }
.d-op { margin: 0 0 var(--e1); }
.d-escalera { margin-top: var(--e3); padding: var(--e2) var(--e3) var(--e3); background: var(--superficie2); border-radius: var(--r-md); }
.d-escalera > .d-h5:first-child { margin-top: var(--e1); }
.d-pista { margin: var(--e2) 0 0; padding: var(--e1) 0 var(--e1) var(--e3); border-left: 3px solid var(--oro); }
.d-pista-cab { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e1) var(--e2); margin-bottom: 2px !important; }
.d-trans { margin: var(--e4) 0; padding: var(--e3) var(--e4); border: 1px dashed var(--borde2); border-radius: var(--r-md); }
.d-desenlace { margin-top: var(--e6); }

/* Imágenes (186A) */
.d-con-fig { display: flex; align-items: flex-start; gap: var(--e4); }
.d-con-fig-txt { flex: 1 1 auto; min-width: 0; }
.d-con-fig-img { flex: none; width: var(--doc-img); }
.d-con-fig-img.d-img-chica { width: var(--doc-img-chica); }
.d-con-fig-img.d-img-grande { width: var(--doc-img-grande); }
.d-con-fig-img.d-img-retrato { width: var(--doc-img-chica); }
.d-fig { margin: 0; }
.d-fig img { display: block; width: 100%; height: auto; border: 1px solid var(--borde); border-radius: var(--r-sm); background: var(--superficie2); }
.d-fig figcaption { margin-top: 2px; font-size: var(--t-xs); color: var(--tenue); line-height: 1.3; }
.d-fig figcaption .d-cod { line-height: 1.3; }
.d-fig-vacia { display: grid; place-items: center; aspect-ratio: 16 / 10; padding: var(--e2); text-align: center; font-size: var(--t-xs); color: var(--tenue); border: 1px dashed var(--borde2); border-radius: var(--r-sm); }

/* Tablas */
.d-tabla { width: 100%; border-collapse: collapse; margin: 0 0 var(--e3); font-size: var(--t-xs); }
.d-tabla th { text-align: left; font-weight: 600; color: var(--texto2); background: var(--superficie2); padding: var(--e1) var(--e2); border-bottom: 1px solid var(--borde2); }
.d-tabla td { padding: var(--e1) var(--e2); border-bottom: 1px solid var(--borde); vertical-align: top; overflow-wrap: anywhere; }
.d-tabla td p { margin: 0; }
.d-col-cod, .d-col-chip { width: 1%; white-space: nowrap; }
.d-tabla-est td { vertical-align: middle; }

/* Tema: muestras en SVG, que se imprimen aunque el navegador no imprima fondos. */
.d-paleta { display: flex; flex-wrap: wrap; gap: var(--e2) var(--e5); margin: 0 0 var(--e3); }
.d-color { display: flex; align-items: center; gap: var(--e2); }
.d-color svg { flex: none; }
.d-color rect { stroke: var(--imp-corte); stroke-width: 1; }
.d-color span { display: flex; flex-direction: column; line-height: 1.3; }
.d-color code { background: none; padding: 0; }

.d-material p { margin-bottom: var(--e3); }
.d-pie { margin: var(--e7) 0 0 !important; padding-top: var(--e3); border-top: 1px solid var(--borde); text-align: center; font-size: var(--t-xs); color: var(--tenue); }

@media (max-width: 600px) {
    .d-f { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .d-con-fig { flex-direction: column-reverse; }
    .d-con-fig-img, .d-con-fig-img.d-img-grande { width: min(100%, var(--doc-img-grande)); }
}

@media print {
    body.hoja-doc { page: documento; background: var(--imp-fondo); }
    .doc-hoja { max-width: none; margin: 0; padding: 0; box-shadow: none; border-radius: 0; }
    .d-portada { break-after: page; }
    .d-sec { break-before: page; margin-top: 0; }
    .d-h2, .d-h3, .d-h4, .d-h5, .d-pt, .d-msg-cab, .d-pista-cab { break-after: avoid; }
    .d-f, .d-msg, .d-pista, .d-op, .d-tabla tr, .d-fig, .d-color, .d-mat-reto, .d-trans, .d-cap, .d-desenlace { break-inside: avoid; }
    .d-pie { break-before: avoid; }
}
@page documento {
    size: auto;
    margin: 16mm 15mm 16mm;
    @top-left { content: var(--doc-cab, ''); font-family: var(--f-texto); font-size: var(--t-xs); color: var(--tenue); }
    @top-right { content: 'METIS'; font-family: var(--f-titulo); font-size: var(--t-xs); letter-spacing: .16em; color: var(--tenue); }
    @bottom-right { content: 'Página ' counter(page) ' de ' counter(pages); font-family: var(--f-texto); font-size: var(--t-xs); color: var(--tenue); }
}
@page documento:first {
    @top-left { content: none; }
    @top-right { content: none; }
}

/* ═══════════════════════════════════════════════════════════════════
   20. SESIONES (fase 3, v0.6.0; D-34, 204A, 205B, 58A).
   Lista, sesión, alumnos y equipos y la proyección del QR. La proyección es siempre clara (usa --imp-fondo
   para el QR). En teléfono, la tabla de partidas se vuelve tarjetas.
   ═══════════════════════════════════════════════════════════════════ */
/* Cabecera de la sesión: título, estado y acciones */
.se-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--e4); flex-wrap: wrap; margin-bottom: var(--e5); }
.se-cab h1 { margin-bottom: var(--e1); }
.se-cab .chip { margin-left: var(--e2); vertical-align: 4px; }
.se-cab p { color: var(--texto2); margin: 0; }

/* Código de la sesión */
.se-cod { font-family: var(--f-mono); font-size: var(--t-xl); font-weight: 700; letter-spacing: .14em; color: var(--tinta-1); }
.se-cod-fila { display: flex; align-items: center; gap: var(--e3); flex-wrap: wrap; }

/* Lista de sesiones */
.se-nombre b { display: block; font-size: var(--t-md); color: var(--tinta-1); }
.se-nombre span { font-size: var(--t-xs); color: var(--tenue); }
.se-integrantes { display: flex; flex-wrap: wrap; gap: var(--e1); }
.se-espera { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e1) var(--e2); margin-top: var(--e1); padding: var(--e1) var(--e2); border-radius: var(--r-md); background: var(--atencion-fondo); color: var(--atencion); border: 1px solid var(--atencion-borde); font-size: var(--t-sm); }
.se-bloque { display: block; }
.se-integrantes .chip.ausente { text-decoration: line-through; opacity: .75; }
.se-etapa b { display: block; font-weight: 600; }
.se-etapa span { font-size: var(--t-xs); color: var(--tenue); }
.se-tiempo { font-family: var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

.se-nowrap { white-space: nowrap; }

/* Panel del alumno: sus sesiones (también en teléfono) */
.se-mis { list-style: none; margin: 0 0 var(--e4); padding: 0; }
.se-mis li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--e2) var(--e4); padding: var(--e3) 0; border-bottom: 1px solid var(--borde); }
.se-mis li > div:first-child { display: flex; flex-direction: column; }
.se-mis-res { display: flex; flex-direction: column; align-items: flex-end; gap: var(--e1); font-size: var(--t-sm); }
@media (max-width: 600px) { .se-mis-res { align-items: flex-start; } }

/* Tablero del formulario de sesión: los botones segmentados de tres valores necesitan más ancho. */
.se-tablero { grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); }
.se-tablero .seg { max-width: 100%; flex-wrap: wrap; height: auto; min-height: var(--d-campo); }

/* Opción de un selector que no se puede elegir (escape room con errores) */
.se-op-bloq { color: var(--tenue); }

/* Alumnos y equipos */
.se-equipos { display: flex; flex-wrap: wrap; gap: var(--e2); margin-bottom: var(--e4); }
.se-equipo { display: flex; flex-direction: column; gap: 2px; min-width: 150px; padding: var(--e2) var(--e3); border: 1px solid var(--borde); border-radius: var(--r-md); background: var(--superficie); }
.se-equipo b { font-size: var(--t-sm); color: var(--tinta-2); }
.se-equipo span { font-size: var(--t-xs); color: var(--tenue); }
.se-equipo.aviso-eq { border-color: var(--atencion-borde); background: var(--atencion-fondo); }
.se-equipo.aviso-eq span { color: var(--atencion); }
button.se-equipo { font: inherit; text-align: left; cursor: pointer; color: inherit; }
button.se-equipo:hover { border-color: var(--acento); }
/* Minutos extra con flechas (205B): − número + */
.se-paso { display: inline-flex; align-items: center; gap: var(--e1); }
.se-paso input { width: 56px; height: 30px; text-align: center; font: inherit; font-size: var(--t-sm); color: var(--texto);
    background: var(--superficie); border: 1px solid var(--borde2); border-radius: var(--r-sm); }
.se-paso .btn-mini { width: 30px; padding: 0; font-size: var(--t-md); }
.se-cab .acciones .tabla select, .se-cab input[type="number"] {
    height: 32px; padding: 0 var(--e2); font: inherit; font-size: var(--t-sm); color: var(--texto);
    background: var(--superficie); border: 1px solid var(--borde2); border-radius: var(--r-sm);
}
.se-nombre b { white-space: nowrap; }

/* Proyección del QR: pantalla completa, sin barra lateral, siempre clara para el proyector */
body.proy { margin: 0; min-height: 100vh; background: var(--superficie); color: var(--texto); font-family: var(--f-texto); }
.proy-rej { min-height: 100vh; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--e7); padding: var(--e7); }
.proy-qr { width: min(78vh, 46vw); aspect-ratio: 1; border: 1px solid var(--borde); border-radius: var(--r-lg); padding: var(--e3); background: var(--imp-fondo); }
.proy-qr svg { display: block; width: 100%; height: 100%; }
.proy-txt { display: flex; flex-direction: column; gap: var(--e5); }
.proy-txt .marca-proy { display: flex; align-items: center; gap: var(--e3); font-family: var(--f-titulo); font-weight: 700; letter-spacing: .08em; color: var(--wordmark); }
.proy-txt h1 { font-size: var(--t-portada); line-height: 1.05; margin: 0; color: var(--tinta-1); }
.proy-txt .sesion { font-size: var(--t-xl); color: var(--texto2); margin: 0; }
.proy-pasos { margin: 0; padding-left: 1.4em; font-size: var(--t-xl); line-height: 1.5; color: var(--texto); }
.proy-pasos b { color: var(--tinta-1); }
.proy-codigo { font-family: var(--f-mono); font-size: clamp(3rem, 6vw, 5.5rem); font-weight: 700; letter-spacing: .16em; color: var(--tinta-1); line-height: 1; }
.proy-pie { display: flex; align-items: center; gap: var(--e4); flex-wrap: wrap; font-size: var(--t-lg); color: var(--texto2); }

/* Teléfono (58A): la tabla de partidas se vuelve tarjetas; las acciones de la sesión, botones anchos */
@media (max-width: 600px) {
    .se-cab .acciones { width: 100%; }
    .se-cab .acciones .btn { flex: 1 1 auto; }
    .se-partidas thead { display: none; }
    .se-partidas, .se-partidas tbody, .se-partidas tr, .se-partidas td { display: block; width: 100%; }
    .se-partidas tr { padding: var(--e3) 0; border-bottom: 1px solid var(--borde); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--e1) var(--e3); }
    .se-partidas td { padding: 0; border: 0; }
    .se-partidas td[data-col="equipo"] { grid-column: 1; }
    .se-partidas td[data-col="estado"] { grid-column: 2; grid-row: 1; text-align: right; }
    .se-partidas td[data-col="integrantes"] { grid-column: 1 / -1; }
    .se-partidas td[data-col="etapa"], .se-partidas td[data-col="tiempo"] { font-size: var(--t-xs); color: var(--tenue); }
    .se-partidas td[data-col="etapa"]::before { content: 'Va en '; }
    .se-partidas td[data-col="tiempo"]::before { content: 'Entró '; }
    .se-ocultar-tel { display: none; }
    .proy-rej { grid-template-columns: 1fr; padding: var(--e5); }
    .proy-qr { width: 100%; }
}
