/* ============================================================================
   LIENZO — dibujo interactivo de la viga (lienzo.js)
   ----------------------------------------------------------------------------
   El SVG llena #ws-modelo (bajo paneles y barras de vidrio); los controles
   flotantes (.lz-ui) se colocan en px dentro de la zona libre que calcula
   lienzo.js. Prefijo .lz-
   ========================================================================== */
#ws-modelo.lz-view { overflow: hidden; }
.lz { position: absolute; inset: 0; overflow: hidden; background: var(--canvas); outline: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* foco del teclado en el lienzo: anillo dentro de la zona libre (fuera de paneles y barras) */
.lz:focus-visible { outline: none; }
.lz:focus-visible::after { content: ''; position: absolute; left: calc(var(--lz-zl, 0px) + 4px); top: calc(var(--lz-zt, 0px) + 4px); right: calc(var(--lz-zr, 0px) + 4px); bottom: calc(var(--lz-zb, 0px) + 4px); z-index: 3; border-radius: 12px; box-shadow: inset 0 0 0 2px var(--accent); pointer-events: none; }
/* tras un clic o un toque en el lienzo no hay anillo: vuelve con la primera tecla (lienzo.js) */
.lz.is-ptr:focus-visible::after { content: none; }
.lz-svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; overflow: hidden; }
.lz.is-dragging, .lz.is-dragging * { cursor: grabbing; }
/* Espacio pulsado: arrastrar desplaza la vista */
.lz.is-space .lz-svg { cursor: grab; }
.lz-fig { display: block; max-width: 100%; height: auto; }

/* capa de controles flotantes */
.lz-ui { position: absolute; inset: 0; pointer-events: none; }
.lz-ui > * { position: absolute; pointer-events: auto; }
.lz-probe { visibility: hidden; pointer-events: none !important; left: 0; top: 0; }
.lz-probe-a { width: var(--ws-l, 0px); height: var(--ws-t, 0px); }
.lz-probe-b { width: var(--ws-r, 0px); height: var(--ws-b, 0px); }
.lz-anchor { width: 1px; height: 1px; pointer-events: none !important; }

/* ---- barra de la selección (escritorio) */
.lz-bar { z-index: 6; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 4px 0 12px; border-radius: 20px; transform: translate(-50%, -100%); white-space: nowrap; font-size: 13px; }
.lz-bar .bubble { margin-left: -4px; }
.lz-lbl { display: inline-flex; align-items: baseline; gap: 0; font-family: var(--math); font-size: 16px; color: var(--ink); white-space: nowrap; }
.lz-lbl sub { font-size: 11px; line-height: 0; position: relative; top: .35em; }   /* flex anula vertical-align: se baja a mano */
.lz-lbl-x { font-size: 15px; }
.lz-eq { margin-left: 5px; font-style: normal; }
.lz-t { font-size: 13px; font-weight: 600; }
.lz-bar .field { width: 64px; flex: none; }
.lz-bar .field:focus, .lz-bar .field:not(:disabled):hover { box-shadow: inset 0 0 0 1.5px var(--accent); }
.lz-bar .field:disabled { color: var(--ink2); background: var(--fill); box-shadow: none; }
.lz-bar .unit { min-width: 0; }
.lz-arrow { color: var(--ink2); font-size: 12px; }
.lz-sep { flex: none; width: 1px; height: 20px; background: var(--sep2); }
.lz-acts { display: flex; align-items: center; }
.lz-ib { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 16px; background: transparent; color: var(--ink); }
.lz-ib:hover { background: var(--fill); }
.lz-ib:active { background: var(--fill2); }
.lz-ib:disabled { opacity: .35; pointer-events: none; }
.lz-ib[data-a="del"] { color: var(--red-text); }
.lz-seg > button { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; padding: 0 6px; }
.lz-seg > button .math { font-size: 15px; }
.lz-seg > button:disabled { opacity: .5; }

/* ---- burbuja de edición (teléfono) */
.lz-bar.is-phone { gap: 4px; height: 52px; padding: 4px; border-radius: 26px; background: var(--glass2); }
.lz-bar.is-phone .lz-ib { width: 44px; height: 44px; border-radius: 22px; }
.lz-bar.is-phone .lz-sep { height: 24px; }
/* sin lugar encima de la selección (hoja abierta): debajo de la viga, colgando de su borde superior */
.lz-bar.is-below { transform: translateX(-50%); }
.lz-bv { display: inline-flex; align-items: baseline; gap: 4px; padding: 0 8px 0 12px; white-space: nowrap; }
.lz-bv .bubble { align-self: center; }
.lz-bv-s { font-family: var(--math); font-size: 17px; }
.lz-bv-s sub { font-size: 11px; }
.lz-bv-e { font-family: var(--math); font-size: 16px; }
.lz-bv-n { font-family: var(--mono); font-size: 15px; }
.lz-bv-u { font-size: 13px; color: var(--ink2); }
.lz-bv-t { font-size: 15px; font-weight: 600; }

/* ---- etiqueta del cursor */
.lz-cur { z-index: 7; display: flex; align-items: center; gap: 8px; height: 24px; padding: 0 8px; border-radius: 12px; font-size: 11.5px; white-space: nowrap; pointer-events: none !important; }
.lz-cur-a { font-weight: 600; color: var(--accent-text); }
.lz-cur-l { font-family: var(--math); font-style: italic; font-size: 14px; line-height: 1; color: var(--ink); }
.lz-cur-x { font-family: var(--mono); font-size: 11px; color: var(--ink2); }
.lz-cur-strong { color: var(--ink); font-weight: 500; }

/* ---- burbuja de inserción */
.lz-ins { z-index: 8; display: flex; align-items: center; gap: 2px; height: 40px; padding: 0 4px 0 8px; border-radius: 20px; transform: translate(-50%, -100%); white-space: nowrap; }
.lz-ins .bubble { margin-right: 4px; }
.lz-ins-x { font-size: 11.5px; color: var(--ink2); margin-right: 6px; }
.lz-ins .lz-sep { margin: 0 4px; }
.lz-ib2 { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; min-width: 32px; height: 32px; padding: 0 10px; border: 0; border-radius: 16px; background: transparent; color: var(--ink); font-size: 12.5px; font-weight: 500; }
.lz-ib2:hover { background: var(--fill); }
.lz-ib2:active { background: var(--fill2); }
.lz-ib2:has(> .ic:only-child) { padding: 0; width: 32px; }
.lz-ib2 .math { font-size: 17px; font-weight: 400; }
.lz-ib2[data-i="close"] { color: var(--ink2); }
.lz-ins.is-phone { height: 52px; padding: 4px 4px 4px 12px; border-radius: 26px; }
.lz-ins.is-phone .lz-ib2 { min-width: 44px; height: 44px; border-radius: 22px; font-size: 13px; padding: 0 10px; }
.lz-ins.is-phone .lz-ib2:has(> .ic:only-child) { width: 44px; padding: 0; }
.lz-ins.is-phone .lz-ins-x { display: none; }
/* teléfono: la burbuja cabe en 390 px. La principal lleva solo los nombres (Apoyo, Carga, Punto);
   Apoyo y Carga, solo los íconos de 44 px (el nombre va en aria-label y title) */
.lz-ins.is-phone:not(.is-sub) .lz-ib2 > .ic:not(:only-child) { display: none; }
.lz-ins.is-phone:not(.is-sub) .lz-ib2 { padding: 0 8px; }
.lz-ins.is-phone.is-sub .lz-ib2 { width: 44px; padding: 0; }
.lz-ins.is-phone.is-sub .lz-ib2 > span, .lz-ins.is-phone.is-sub .lz-sep { display: none; }

/* ---- ayuda de gestos */
.lz-hint { z-index: 4; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 17px; font-size: 12px; color: var(--ink2); white-space: nowrap; overflow: hidden; pointer-events: none !important; }
.lz-hint .ic { color: var(--ink2); }
/* bloque (no flex) para que un texto largo termine en «…» en lugar de cortarse */
.lz-ht { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lz-ht > * + * { margin-left: 8px; }
.lz-hs { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; }
.lz-dot { width: 9px; height: 9px; border-radius: 5px; background: var(--raised); box-shadow: inset 0 0 0 1.5px var(--accent); }
.lz-sq { width: 9px; height: 9px; border-radius: 2px; background: var(--accent); }
.lz-hm { font-size: 14px; color: var(--ink); }
.lz-hm sub { font-size: 10px; line-height: 0; }

/* ---- herramienta activa (escritorio y tableta): ícono, nombre y Terminar (Esc),
        arriba al centro de la zona libre. En el teléfono, el aviso de movil.js */
.lz-tool { z-index: 5; display: flex; align-items: center; gap: 8px; width: max-content; height: 36px; padding: 0 4px 0 12px; border-radius: 18px; transform: translateX(-50%); white-space: nowrap; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.lz-tool > .ic { flex: none; color: var(--accent-text); }
.lz-tool-end { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 12px 0 8px; border: 0; border-radius: 14px; background: var(--fill); color: var(--ink); font-size: 12px; font-weight: 600; }
.lz-tool-end:hover { background: var(--fill2); }
.lz-tool-end .ic { color: var(--ink2); }

/* ---- lienzo sin viga: aviso al centro de la zona libre (solo el botón recibe clics) */
.lz-empty { z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 2px; width: max-content; max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 18px; transform: translate(-50%, -100%); text-align: center; pointer-events: none !important; }
.lz-empty-t { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.lz-empty-s { font-size: 12.5px; color: var(--ink2); }
.lz-empty-b { margin-top: 8px; pointer-events: auto; }
.lz.is-phone .lz-empty-b { height: 44px; padding: 0 18px; border-radius: 22px; font-size: 14px; }

/* ---- campo flotante: largo exacto de un tramo (herramienta Viga) o medida de una cota */
.lz-ed { z-index: 9; display: flex; align-items: center; gap: 6px; width: max-content; height: 36px; padding: 0 6px 0 10px; border-radius: 18px; transform: translate(-50%, -50%); white-space: nowrap; font-size: 13px; }
.lz-ed .field { width: 84px; flex: none; }
.lz-ed .unit { min-width: 0; padding-right: 4px; }
.lz-ed.is-phone { height: 52px; padding: 0 8px 0 14px; border-radius: 26px; }
.lz-ed.is-phone .field { height: 44px; width: 96px; font-size: 16px; }   /* 16 px: iOS no acerca la página al enfocar */

/* ---- zoom */
.lz-zoom { z-index: 5; display: flex; justify-content: flex-end; gap: 8px; }
.lz-zcap { display: flex; align-items: center; height: 34px; padding: 0 2px; border-radius: 17px; }
.lz-zb { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 28px; padding: 0; border: 0; border-radius: 14px; background: transparent; color: var(--ink); }
.lz-zb:hover { background: var(--fill); }
.lz-zpct { width: 48px; text-align: center; font-size: 11.5px; color: var(--ink); }
.lz-zfit { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 17px; color: var(--ink); }
.lz-zfit:hover { filter: brightness(1.04); }

/* ---- al resolver, las reacciones y los objetivos aparecen con una transición breve (lienzo.js: fadeResults) */
.lz-fade { animation: lz-fade 320ms ease-out both; }
@keyframes lz-fade { from { opacity: .15; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .lz-fade { animation: none; } }

@media print { .lz-ui { display: none; } }
