/* ============================================================
   CYD STUDIO — tema retro 8-bit (negro / rojo / amarillo ZX)
   CSS puro, sin frameworks ni builds.
   ============================================================ */

* { box-sizing: border-box; }

/* el atributo hidden siempre gana a cualquier display del CSS */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0e0c09;
  color: #e8e3d5;
  font-family: 'VT323', ui-monospace, 'Courier New', monospace;
  font-size: 15px;
  line-height: 1.35;
}

.font-pixel { font-family: 'Press Start 2P', ui-monospace, monospace; }
.font-mono, code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* --- scrollbars retro --- */
* { scrollbar-width: thin; scrollbar-color: #3f382a #0e0c09; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #0e0c09; }
::-webkit-scrollbar-thumb { background: #3f382a; border: 2px solid #0e0c09; }
::-webkit-scrollbar-thumb:hover { background: #5c5138; }

:focus-visible { outline: 2px solid #ffd94a; outline-offset: 1px; }

/* ============================================================
   ESQUELETO GENERAL: cabecera / cuerpo / herramientas
   ============================================================ */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
}

/* ---------- cabecera ---------- */
#cabecera {
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #171310;
  border-bottom: 2px solid #3f382a;
}
#cabecera h1 {
  display: flex; align-items: center; gap: 6px;
  margin: 0;
  font-family: 'Press Start 2P', ui-monospace, monospace;
  font-size: 13px;
  letter-spacing: 1px;
  color: #ffd94a;
}
#cabecera h1 img {
  height: 24px; width: 24px; flex-shrink: 0;
  border: 1px solid #3f382a; border-radius: 3px;
}
#cabecera h1 .h1-punto { color: #ff6b6b; }
.subtitulo {
  font-size: 11px; line-height: 1.15; color: #6a6355;
  font-family: ui-monospace, monospace;
}
.titulo-juego { width: 180px; font-weight: bold; font-family: inherit; }
@media (min-width: 640px) { .titulo-juego { width: 220px; } }
.cabecera-derecha { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sep-v { width: 1px; height: 20px; background: #3f382a; margin: 0 2px; }

/* ---------- cuerpo: columna izquierda (grafo + herramientas) + panel de escenas ----------
   El panel de escenas es una columna derecha independiente que llega hasta abajo:
   por eso las herramientas inferiores ya no ocupan todo el ancho de la pantalla. */
#cuerpo {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

/* columna izquierda: el grafo arriba y las herramientas debajo */
#cuerpo-izquierda {
  display: flex;
  flex-direction: column;
  flex: 65 1 0%;
  min-height: 0;
  min-width: 0;
}

#zona-trabajo {
  display: flex;
  flex-direction: row;
  flex: 65 1 0%;
  min-height: 0;
}
#panel-herramientas {
  display: flex;
  flex-direction: column;
  flex: 35 1 0%;
  min-height: 0;
  background: #0e0c09;
  z-index: 10;
}
/* plegado: la zona de trabajo gana todo el alto */
#cuerpo.plegado #zona-trabajo { flex: 1 1 auto; }
#cuerpo.plegado #splitter-y,
#cuerpo.plegado #contenido-pestanas { display: none; }
#cuerpo.plegado #panel-herramientas { flex: 0 0 auto; }

#panel-grafo {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}
#panel-escena {
  display: flex;
  flex-direction: column;
  flex: 0 0 26%;
  min-width: 260px;
  max-width: 60%;
  background: #12100c;
  border-left: 2px solid #3f382a;
}
@media (max-width: 1023px) {
  /* en pantallas estrechas volvemos a apilar: grafo, escenas, herramientas */
  #cuerpo { flex-direction: column; }
  #cuerpo-izquierda { display: contents; }
  #splitter-x { display: none; }
  #panel-escena { order: 2; flex: 0 0 auto; min-width: 0; max-width: none; height: 40%; border-left: none; border-top: 2px solid #3f382a; }
  #splitter-y { order: 3; }
  #panel-herramientas { order: 4; }
}

/* ---------- separadores redimensionables ---------- */
.retro-splitter { position: relative; background: #171310; z-index: 5; transition: background 0.1s; flex: 0 0 auto; }
.retro-splitter-y { height: 9px; cursor: row-resize; border-top: 2px solid #3f382a; border-bottom: 2px solid #2a2418; }
.retro-splitter-y::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 36px; height: 2px; transform: translate(-50%, -50%);
  background: #4a4130;
}
.retro-splitter-x { width: 9px; cursor: col-resize; border-left: 2px solid #3f382a; border-right: 2px solid #2a2418; }
.retro-splitter-x::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 2px; height: 36px; transform: translate(-50%, -50%);
  background: #4a4130;
}
.retro-splitter:hover { background: #241d12; }
.retro-splitter:hover::after { background: #ffd94a; }

/* ---------- barra de pestañas inferior (SIEMPRE visible) ---------- */
#barra-pestanas {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 0;
  background: #171310;
  border-bottom: 2px solid #3f382a;
  flex: 0 0 auto;
}
.pestana {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  padding: 6px 12px;
  background: transparent;
  color: #8a8271;
  border: 2px solid transparent;
  border-bottom: none;
  cursor: pointer;
}
.pestana:hover { color: #e8e3d5; }
.pestana.activa { border-color: #ffd94a; background: #0e0c09; color: #ffd94a; }
.pestana-n {
  margin-left: 4px; padding: 0 4px; font-size: 10px;
  background: #ffd94a; color: #000;
}
.pestana-n.errores { background: #ff4444; }
.plegar { margin-left: auto; margin-bottom: 4px; }

#contenido-pestanas { flex: 1; min-height: 0; overflow: hidden; }
.panel-tab { display: none; height: 100%; min-height: 0; }
.panel-tab.activa { display: block; }

/* ============================================================
   BOTONES / INPUTS / PANELES RETRO
   ============================================================ */
.retro-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 2px solid #4a4130;
  background: #1c1814;
  color: #e8e3d5;
  padding: 4px 10px;
  font-family: 'VT323', ui-monospace, monospace;
  font-size: 15px;
  line-height: 1.1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 2px 2px 0 #000;
  transition: none;
  user-select: none;
}
.retro-btn:hover:not(:disabled) { border-color: #ffd94a; color: #ffd94a; }
.retro-btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 0 0 0 #000; }
.retro-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.retro-btn--accent { border-color: #ffd94a; color: #ffd94a; }
.retro-btn--primary { border-color: #ffd94a; background: #ffd94a; color: #000; font-weight: bold; }
.retro-btn--primary:hover:not(:disabled) { background: #ffe873; color: #000; }
.retro-btn--danger { border-color: #ff4444; color: #ff6b6b; }
.retro-btn--danger:hover:not(:disabled) { border-color: #ff6b6b; color: #ff9d9d; }

.retro-mini {
  border: 1px solid #4a4130;
  background: #1c1814;
  color: #b5ac97;
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 3px 6px;
  cursor: pointer;
}
.retro-mini:hover:not(:disabled) { border-color: #ffd94a; color: #ffd94a; }
.retro-mini:disabled { opacity: 0.4; cursor: not-allowed; }
.retro-mini--danger:hover:not(:disabled) { border-color: #ff4444; color: #ff6b6b; }

.retro-chip {
  border: 1px solid #4a4130;
  background: #171310;
  color: #b5ac97;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  padding: 2px 6px;
  cursor: pointer;
}
.retro-chip:hover { border-color: #ffd94a; color: #ffd94a; }
.retro-chip--accent { border-color: #ffd94a; color: #ffd94a; }

.retro-input {
  /*width: 200px;*/
  max-width: 200px;
  border: 2px solid #3f382a;
  background: #0c0a07;
  color: #e8e3d5;
  padding: 4px 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.retro-input:focus { border-color: #ffd94a; }
.retro-input--hash { padding-left: 24px; }

.retro-label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a8271;
  font-family: inherit;
}

.retro-panel {
  border: 2px solid #3f382a;
  background: #171310;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.9);
}

.rojo { color: #ff6b6b; }
.verde { color: #4dff88; }

/* ============================================================
   GRAFO DE ESCENAS
   ============================================================ */
#grafo-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #0e0c09;
  background-image: radial-gradient(#3a3223 1.6px, transparent 1.6px);
  background-size: 26px 26px;
  background-position: 0 0;
  cursor: default;
  user-select: none;
}
#grafo-viewport.pan { cursor: grabbing; }

#grafo-mundo {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

#grafo-svg {
  position: absolute;
  top: -10000px;
  left: -10000px;
  width: 40000px;
  height: 40000px;
  overflow: hidden;
  pointer-events: none;
}
#grafo-aristas, #grafo-temporal { pointer-events: none; }
#grafo-aristas path, #grafo-temporal path { pointer-events: stroke; }

.arista {
  fill: none;
  stroke-width: 1.7;
  cursor: pointer;
}
.arista-recableable { cursor: grab; }
.arista:hover { stroke-width: 3px; filter: brightness(1.35); }
.arista-goto { stroke-dasharray: 7 5; animation: arista-dash 0.9s linear infinite; }
@keyframes arista-dash { to { stroke-dashoffset: -24; } }
.arista-rota { stroke-dasharray: 4 4; }

.etiqueta-arista rect { fill: #14110d; }
.etiqueta-arista text {
  font-family: ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
}
.arista:hover + .etiqueta-arista text,
.etiqueta-arista:hover text { font-weight: 700; }

/* ---------- tarjetas de escena ---------- */
.nodo {
  position: absolute;
  width: 240px;
  background: #141210;
  border: 2px solid #3f382a;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.9);
  cursor: grab;
}
.nodo:active { cursor: grabbing; }
.nodo:hover { border-color: #6a5c3a; }
.nodo.seleccionada { border-color: #ffd94a; }
/* escena activa del simulador: brillo rojo pulsante */
.nodo.previa {
  border-color: #ff4444;
  z-index: 5;
  animation: pulso-previa 1.05s ease-in-out infinite;
}
@keyframes pulso-previa {
  0%, 100% {
    box-shadow: 0 0 0 2px rgba(255, 68, 68, 0.45), 0 0 10px 2px rgba(255, 68, 68, 0.30),
                5px 5px 0 rgba(0, 0, 0, 0.9);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(255, 68, 68, 0.95), 0 0 24px 8px rgba(255, 68, 68, 0.65),
                5px 5px 0 rgba(0, 0, 0, 0.9);
  }
}
@media (prefers-reduced-motion: reduce) {
  .nodo.previa {
    animation: none;
    box-shadow: 0 0 0 3px rgba(255, 68, 68, 0.9), 0 0 16px 4px rgba(255, 68, 68, 0.5),
                5px 5px 0 rgba(0, 0, 0, 0.9);
  }
}
.nodo-cab {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  background: #1c1814;
  border-bottom: 2px solid #3f382a;
}
.nodo-label {
  font-family: ui-monospace, monospace;
  font-size: 12px; font-weight: bold;
  color: #ffd94a;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nodo-badges { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.badge {
  font-family: ui-monospace, monospace;
  font-size: 9px; line-height: 16px;
  padding: 0 4px;
  border: 1px solid #8a8271;
  color: #b5ac97;
  white-space: nowrap;
}
.badge-inicio { border-color: #ffd94a; color: #ffd94a; }
.badge-fin { border-color: #ff4444; color: #ff6b6b; }
.badge-img { border-color: #00a1a1; color: #00ffff; }
.badge-rota { border-color: #ff4444; background: #ff444422; color: #ff6b6b; }
.nodo-cuerpo { padding: 6px 8px 4px; }
.nodo-titulo {
  font-size: 14px; font-weight: bold; color: #e8e3d5;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nodo-resumen {
  margin: 2px 0 0;
  height: 42px;
  overflow: hidden;
  font-family: ui-monospace, monospace;
  font-size: 10.5px; line-height: 14px;
  color: #8a8271;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.nodo-pies { padding: 4px 8px; border-top: 1px solid #2a2418; }
.nodo-opcion {
  font-family: ui-monospace, monospace;
  font-size: 10px; line-height: 16px;
  color: #b5ac97;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nodo-opcion .destino { color: #9a917d; }
.nodo-sinopciones { font-size: 11px; font-style: italic; color: #5c5546; }
.nodo-mas { font-size: 10px; color: #5c5546; font-family: ui-monospace, monospace; }

/* ---------- puertos (handles) ---------- */
.puerto {
  position: absolute;
  width: 11px; height: 11px;
  background: var(--puerto, #b5ac97);
  border: 2px solid #000;
  box-shadow: 0 0 0 1px var(--puerto, #b5ac97);
  cursor: crosshair;
  z-index: 3;
}
.puerto::after { content: ''; position: absolute; inset: -9px; }
.puerto-top { top: -7px; left: calc(50% - 6px); }
.puerto-bottom { bottom: -7px; }
.puerto-fantasma { width: 6px; height: 6px; opacity: 0; pointer-events: none; top: -4px; left: calc(50% - 3px); }

/* ---------- nodo fantasma (enlace roto) ---------- */
.nodo-fantasma {
  position: absolute;
  padding: 6px 10px;
  background: #190d0d;
  border: 2px dashed #ff4444;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.9);
  cursor: grab;
  white-space: nowrap;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: #ff6b6b;
}

/* ---------- controles flotantes del grafo ---------- */
#grafo-controles {
  position: absolute;
  left: 12px; bottom: 12px;
  display: flex;
  flex-direction: column;
  border: 2px solid #3f382a;
  background: #171310;
  box-shadow: 3px 3px 0 #000;
  z-index: 10;
}
#grafo-controles button {
  width: 26px; height: 26px;
  background: #171310;
  border: none;
  border-bottom: 1px solid #3f382a;
  color: #b5ac97;
  font-size: 15px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
#grafo-controles button:last-child { border-bottom: none; }
#grafo-controles button:hover { background: #221d15; color: #ffd94a; }

#grafo-botones {
  position: absolute;
  right: 12px; top: 12px;
  display: flex; gap: 8px;
  z-index: 10;
}
#grafo-leyenda-btn { position: absolute; right: 12px; bottom: 12px; z-index: 10; }

#grafo-leyenda {
  position: absolute;
  right: 12px; bottom: 12px;
  z-index: 11;
  max-width: 260px;
  padding: 8px 12px;
  background: #171310f2;
  border: 2px solid #3f382a;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.9);
  font-family: ui-monospace, monospace;
  font-size: 10px;
  line-height: 18px;
  color: #b5ac97;
}
.leyenda-titulo {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 0 4px;
  font-family: 'Press Start 2P', ui-monospace, monospace;
  font-size: 9px;
  color: #ffd94a;
}
.leyenda-linea { margin: 0; display: flex; align-items: center; gap: 6px; }
.leyenda-muestra { display: inline-flex; gap: 3px; flex-shrink: 0; }
.leyenda-muestra span { display: inline-block; width: 12px; height: 3px; }
.leyenda-trazo {
  display: inline-block; width: 16px; height: 0; flex-shrink: 0;
  border-top: 2px solid #e8e3d5;
}
.leyenda-trazo.punteada { border-top-style: dashed; }
.leyenda-pie { margin: 4px 0 0; padding-top: 4px; border-top: 1px solid #3f382a; font-size: 9px; color: #8a8271; }

#grafo-vacio {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 10;
}
.vacio-caja { max-width: 380px; padding: 24px; text-align: center; }
.vacio-titulo { margin: 0; font-family: 'Press Start 2P', monospace; font-size: 13px; color: #ffd94a; }
.vacio-caja p + p { margin-top: 12px; color: #b5ac97; }

/* ============================================================
   EDITOR DE ESCENA
   ============================================================ */
.escena-raiz { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.escena-vacia {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 32px; text-align: center;
}
.escena-vacia .logo-grande {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px; line-height: 2; color: #ffd94a;
}
.escena-vacia p { margin: 0; max-width: 280px; color: #8a8271; font-size: 14px; }
.escena-vacia ul { margin: 0; padding-left: 0; list-style: none; text-align: left; font-size: 13px; color: #6a6355; }
.escena-vacia li { margin-bottom: 4px; }

.escena-cab {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: #171310;
  border-bottom: 2px solid #3f382a;
  flex: 0 0 auto;
}
.escena-cab .rotulo { font-family: 'Press Start 2P', monospace; font-size: 10px; color: #ffd94a; }
.escena-cab .acciones { margin-left: auto; display: flex; gap: 6px; }

.escena-cuerpo {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.escena-grid-id { display: grid; grid-template-columns: 1fr 170px; gap: 8px; }
@media (max-width: 1279px) { .escena-grid-id { grid-template-columns: 1fr; } }
.aviso-etiqueta { margin: 0; font-size: 12px; color: #ff6b6b; }

.avisos-escena {
  border: 2px solid #8a6a1f;
  background: #1c1810;
  padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.avisos-escena p { margin: 0; font-size: 12px; color: #ffd94a; }
.avisos-escena p.error { color: #ff6b6b; }

.cabecera-bloque { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cabecera-bloque .retro-label { margin: 0; }

/* ---------- editor de código CYD ---------- */
.code-editor {
  border: 2px solid #3f382a;
  background: #0c0a07;
  box-shadow: 3px 3px 0 #000;
}
.code-editor .barra-snippets {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 6px;
  background: #171310;
  border-bottom: 2px solid #3f382a;
}
.code-editor .zona { position: relative; }
.code-editor pre.code-layer {
  margin: 0;
  padding: 12px;
  min-height: 260px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 20px;
  white-space: pre;
  tab-size: 2;
}
.code-editor textarea.code-layer {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  min-height: 260px;
  padding: 12px;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: #ffe94a;
  border: none;
  outline: none;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 20px;
  white-space: pre;
  tab-size: 2;
}
.code-editor textarea.code-layer::selection { background: #ffe94a33; }
.t-text { color: #d8d2c0; }
.t-cmd { color: #ffd94a; }
.t-bracket { color: #7a6a30; }
.t-label { color: #4dff88; }
.t-comment { color: #6a6355; font-style: italic; }
.t-dim { color: #443e30; }
.t-err { color: #ff6b6b; background: #3a1210; text-decoration: underline wavy #ff4444; }

.code-editor .pie {
  padding: 4px 8px;
  background: #171310;
  border-top: 2px solid #3f382a;
  font-size: 12px;
  color: #8a8271;
}
.code-editor .pie code { color: #ffd94a; }
.code-editor .pie code.verde { color: #4dff88; }

.sugerencias {
  position: absolute;
  z-index: 50;
  width: 360px;
  max-height: 220px;
  overflow-y: auto;
  margin: 0; padding: 0; list-style: none;
  background: #171310;
  border: 2px solid #ffd94a;
  box-shadow: 4px 4px 0 #000;
  font-size: 13px;
}
.sugerencias button {
  display: flex; align-items: flex-start; gap: 8px;
  width: 100%;
  padding: 5px 8px;
  background: transparent; border: none;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  text-align: left;
  color: #d8d2c0;
  cursor: pointer;
}
.sugerencias button:hover { background: #2a2318; }
.sugerencias button.sel { background: #ffd94a; color: #000; }
.sugerencias button.sel .tipo,
.sugerencias button.sel .sug-sintaxis,
.sugerencias button.sel .sug-desc { color: #1c1814; }
.sugerencias .tipo {
  font-size: 11px;
  color: #7a7466;
  flex: 0 0 auto;
  padding-top: 2px;
}
.sugerencias .tipo.hash { color: #4dff88; }
/* Contenedor de nombre + sintaxis + descripción */
.sugerencias .sug-cont {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}
.sugerencias .sug-nombre {
  font-weight: bold;
  font-size: 13px;
  color: inherit;
}
.sugerencias .sug-sintaxis {
  font-size: 12px;
  color: #ffd94a;
  font-family: ui-monospace, monospace;
}
.sugerencias button.sel .sug-sintaxis { color: #1c1814; }
.sugerencias .sug-desc {
  font-size: 11px;
  color: #8a8271;
  font-style: italic;
  line-height: 1.2;
}
.sugerencias button.sel .sug-desc { color: #2a2418; }
.sugerencias button.sel .sug-nombre { color: #000; }

/* ---------- opciones de la escena ---------- */
.opcion-caja {
  border: 2px solid #3f382a;
  background: #12100c;
  padding: 8px;
}
.opcion-fila { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.opcion-fila .num { font-family: ui-monospace, monospace; font-size: 12px; }
.opcion-destino { display: flex; align-items: center; gap: 4px; }
.opcion-destino .flecha { font-size: 12px; color: #6a6355; white-space: nowrap; }
.opcion-destino .hash { font-family: ui-monospace, monospace; color: #4dff88; }
.aviso-destino { margin: 4px 0 0; font-size: 12px; color: #ff6b6b; }
.sin-opciones-nota { margin: 0 0 8px; font-size: 12px; color: #6a6355; }
.sin-opciones-nota code { color: #ffd94a; }

/* ============================================================
   SIMULADOR (pestaña 1)
   ============================================================ */
.simulador { display: flex; flex-direction: column; gap: 12px; height: 100%; min-height: 0; padding: 12px; }
@media (min-width: 1024px) { .simulador { flex-direction: row; } }
.sim-area {
  flex: 1;
  min-height: 0; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.sim-tv {
  position: relative;
  flex-shrink: 0;
  border: 6px solid #2a2418;
  background: #000;
  box-shadow: 6px 6px 0 #000;
}
#sim-canvas { display: block; width: 100%; aspect-ratio: 4 / 3; cursor: pointer; image-rendering: pixelated; }
.sim-vineta {
  pointer-events: none;
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, 0.38) 100%);
}
.scanlines::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg,
    rgba(0, 0, 0, 0.22) 0px, rgba(0, 0, 0, 0.22) 1px,
    transparent 1px, transparent 3px);
  pointer-events: none;
  z-index: 5;
}
.sim-controles {
  width: 100%;
  flex-shrink: 0;
  display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto;
}
@media (min-width: 1024px) { .sim-controles { width: 300px; } }
.sim-fila { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sim-velocidad { margin-left: auto; display: flex; align-items: center; gap: 4px; font-size: 12px; color: #8a8271; }
.select-vel { width: auto; padding: 2px 4px; font-size: 12px; }
.sim-estado {
  white-space: pre-line;
  border: 2px solid #3f382a;
  background: #12100c;
  padding: 8px;
  font-family: ui-monospace, monospace;
  font-size: 12.5px;
  color: #b5ac97;
}
.sim-estado.fin { border-color: #4dff88; background: #10240f; color: #7dffab; }
.sim-estado.error { border-color: #ff4444; background: #2a1210; color: #ff6b6b; }
.sim-opciones { display: flex; flex-direction: column; gap: 6px; }
.sim-opciones .retro-btn { width: 100%; justify-content: flex-start; text-align: left; font-size: 13px; text-transform: none; letter-spacing: 0; }
.sim-opciones .num-opt { color: #ffd94a; }
.sim-opciones .destino-opt { color: #4dff88; }
.sim-nota { margin-top: auto; font-size: 12px; line-height: 1.35; color: #5c5546; }

/* ============================================================
   VALIDACIÓN (pestaña 2)
   ============================================================ */
.validacion { display: flex; flex-direction: column; height: 100%; min-height: 0; padding: 12px; }
.validacion-cab { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 8px; font-size: 13px; }
.validacion-cab .rotulo { font-family: 'Press Start 2P', monospace; font-size: 10px; color: #ffd94a; }
.validacion-cab .meta { color: #8a8271; }
.validacion-cab .err-n { color: #7dffab; }
.validacion-cab .err-n.mal { color: #ff6b6b; }
.validacion-cab .av-n { color: #7dffab; }
.validacion-cab .av-n.mal { color: #ffd94a; }
.validacion-lista { flex: 1; min-height: 0; overflow-y: auto; }
.validacion-lista ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.validacion-item {
  display: block; width: 100%;
  border: 2px solid #8a6a1f66; background: #1e180c;
  padding: 6px 10px;
  text-align: left;
  font-family: ui-monospace, monospace;
  font-size: 12.5px;
  color: #ffe08a;
  cursor: pointer;
}
.validacion-item:hover { border-color: #ffd94a; }
.validacion-item.error { border-color: #ff444466; background: #221010; color: #ff9d9d; }
.validacion-item.error:hover { border-color: #ff4444; }
.validacion-item .escena { color: #e8e3d5; margin-right: 4px; }
.validacion-ok { margin-top: 24px; max-width: 440px; padding: 16px; text-align: center; }
.validacion-ok .ok-titulo { margin: 0; font-family: 'Press Start 2P', monospace; font-size: 11px; color: #7dffab; }
.validacion-ok p + p { margin: 8px 0 0; font-size: 13.5px; color: #b5ac97; }

/* ============================================================
   CHULETA (pestaña 3)
   ============================================================ */
.chuleta { height: 100%; min-height: 0; overflow-y: auto; padding: 12px; }
.chuleta-cab { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.chuleta-cab .rotulo { font-family: 'Press Start 2P', monospace; font-size: 10px; color: #ffd94a; }
.chuleta-cab .meta { font-size: 12px; color: #8a8271; }
.chuleta-reglas { display: grid; gap: 8px; grid-template-columns: 1fr; margin-bottom: 16px; }
@media (min-width: 768px) { .chuleta-reglas { grid-template-columns: repeat(3, 1fr); } }
.chuleta-reglas .regla { border: 2px solid #3f382a; background: #12100c; padding: 10px; font-size: 12.5px; color: #b5ac97; }
.chuleta-reglas .regla .titulo { margin-bottom: 4px; font-family: ui-monospace, monospace; }
.chuleta-reglas .regla code { color: #ffd94a; }
.chuleta-reglas .regla-img code { color: #00ffff; }
.chuleta-reglas .regla .titulo.c-amar { color: #ffd94a; }
.chuleta-reglas .regla .titulo.c-verde { color: #4dff88; }
.chuleta-reglas .regla .titulo.c-cian { color: #00ffff; }
.chuleta-comandos { display: grid; gap: 8px; grid-template-columns: 1fr; margin-bottom: 16px; }
@media (min-width: 1024px) { .chuleta-comandos { grid-template-columns: 1fr 1fr; } }
.cmd-grupo { border: 2px solid #3f382a; background: #12100c; }
.cmd-grupo .cab { padding: 4px 10px; background: #1c1814; border-bottom: 2px solid #3f382a; font-family: ui-monospace, monospace; font-size: 11.5px; color: #ffd94a; }
.cmd-grupo table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.cmd-grupo tr { border-bottom: 1px solid #221d15; }
.cmd-grupo tr:last-child { border-bottom: none; }
.cmd-grupo td { padding: 4px 8px; vertical-align: top; color: #b5ac97; }
.cmd-grupo td.sintaxis { width: 130px; font-family: ui-monospace, monospace; font-size: 11.5px; color: #7dffab; }
.chuleta-ejemplo-cab { display: flex; align-items: center; gap: 8px; margin-bottom: 0; }
.chuleta-ejemplo-cab .retro-label { margin: 0; }
.chuleta pre.cyd-code {
  margin: 0;
  overflow-x: auto;
  border: 2px solid #3f382a;
  background: #0c0a07;
  padding: 12px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  line-height: 20px;
}
.chuleta-compilar { margin-top: 16px; border: 2px solid #3f382a; background: #12100c; padding: 10px; font-size: 12.5px; color: #b5ac97; }
.chuleta-compilar .titulo { margin-bottom: 4px; font-family: 'Press Start 2P', monospace; font-size: 10px; color: #ffd94a; }
.chuleta-compilar ol { margin: 4px 0 0; padding-left: 20px; }
.chuleta-compilar li { margin-bottom: 2px; }
.chuleta-compilar code { color: #7dffab; }
.chuleta-pie { margin-top: 12px; text-align: center; font-size: 10.5px; color: #5c5546; }

/* ============================================================
   DIÁLOGO MODAL
   ============================================================ */
#modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-fondo { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); }
.modal-caja {
  position: relative;
  width: min(440px, calc(100vw - 32px));
  padding: 16px;
}
.modal-titulo { margin: 0 0 8px; font-family: 'Press Start 2P', monospace; font-size: 12px; color: #ffd94a; }
.modal-titulo.peligro { color: #ff6b6b; }
.modal-texto { margin: 0 0 16px; font-size: 14px; color: #b5ac97; }
.modal-texto .destacado { color: #ffd94a; }
.modal-botones { display: flex; justify-content: flex-end; gap: 8px; }

/* ============================================================
   AVISOS (toasts)
   ============================================================ */
#toasts {
  position: fixed;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: baseline; gap: 8px;
  max-width: min(520px, calc(100vw - 40px));
  padding: 8px 14px;
  background: #1c1814;
  border: 2px solid #4a4130;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.9);
  font-size: 13.5px;
  color: #e8e3d5;
  pointer-events: auto;
  animation: toast-entra 0.15s steps(3, end);
}
.toast .t-desc { display: block; font-size: 11.5px; color: #8a8271; }
.toast.exito { border-color: #4dff88; }
.toast.aviso { border-color: #ffd94a; }
.toast.error { border-color: #ff4444; }
.toast.info { border-color: #4dd8ff; }
@keyframes toast-entra { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* destello retro al saltar desde una arista a su opción en el editor */
@keyframes cyd-flash {
  0%, 55% { background-color: rgba(255, 217, 74, 0.3); border-color: #ffd94a; }
  100% { background-color: #12100c; }
}
.option-flash { animation: cyd-flash 1.3s steps(5, end) 1; }

/* ============================================================
   PESTAÑA COMPILAR — layout con tabs verticales (sin scroll)
   ============================================================ */
.compilar-raiz {
  height: 100%;
  overflow: hidden;
  background: #0e0c09;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: 'VT323', ui-monospace, monospace;
}

.compilar-cab {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: #171310;
  border: 2px solid #3f382a;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.9);
  flex: 0 0 auto;
}
.compilar-cab .rotulo {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #ffd94a;
}
.compilar-cab .meta {
  color: #b5ac97;
  flex: 1 1 200px;
  font-size: 15px;
}
.compilar-acciones {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.compilar-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 15px;
  color: #e8e3d5;
  cursor: pointer;
}
.compilar-check input { cursor: pointer; width: 14px; height: 14px; }

/* Cuerpo: 2 bloques (formulario | salidas), cada uno con sus tabs verticales */
.compilar-cuerpo {
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(320px, 1fr);
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
}
@media (max-width: 1100px) {
  .compilar-cuerpo { grid-template-columns: 1fr; }
}

/* Bloque: tabs verticales a la izquierda + contenido a la derecha */
.compilar-bloque {
  display: flex;
  flex-direction: row;
  background: #171310;
  border: 2px solid #3f382a;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.9);
  overflow: hidden;
  min-height: 0;
}

/* --- Tabs verticales (barra lateral izquierda) --- */
.compilar-vtabs {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  background: #0c0a07;
  border-right: 2px solid #3f382a;
  padding: 4px;
  gap: 2px;
  min-width: 130px;
  overflow: visible;  /* la barra no scrolla; si hace falta, scrolla el contenido */
}
.compilar-vtab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: transparent;
  color: #8a8271;
  border: 2px solid transparent;
  border-left: 3px solid transparent;
  cursor: pointer;
  font-family: 'VT323', ui-monospace, monospace;
  font-size: 15px;
  text-align: left;
  letter-spacing: 0.02em;
  transition: none;
  flex: 0 0 auto;
}
.compilar-vtab:hover { color: #e8e3d5; background: #1c1814; }
.compilar-vtab.activa {
  color: #ffd94a;
  border-left-color: #ffd94a;
  background: #171310;
}
.compilar-vtab-icon { font-size: 16px; flex: 0 0 auto; }
.compilar-vtab-label { flex: 1 1 auto; }

/* Botón Generar al principio de los tabs verticales (siempre visible) */
.compilar-vtab-generar {
  margin-bottom: 8px;
  width: 100%;
  justify-content: center;
  font-size: 15px;
  padding: 8px;
  flex: 0 0 auto;
}

/* --- Contenido de la sección activa (derecha de los tabs) --- */
.compilar-vcontenido {
  flex: 1 1 auto;
  padding: 10px 12px;
  overflow: auto;
  min-width: 0;
}

/* Título de la sección dentro del contenido */
.compilar-seccion-titulo {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: #ffd94a;
  margin: 0 0 10px 0;
  padding-bottom: 6px;
  border-bottom: 2px solid #3f382a;
  letter-spacing: 0.04em;
}

/* Contenedor de campos (grid de 2 columnas para apilar dos por fila) */
.compilar-campos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}
@media (max-width: 700px) {
  .compilar-campos { grid-template-columns: 1fr; }
}

/* Cada fila: etiqueta arriba, control abajo */
.compilar-fila {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 2px 0;
  min-width: 0;
}
.compilar-fila .retro-label {
  margin: 0;
  font-size: 15px;
  color: #e8e3d5;
  text-transform: none;
  letter-spacing: 0;
  font-family: 'VT323', ui-monospace, monospace;
  line-height: 1.1;
}
.compilar-control {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.compilar-control .retro-input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  flex: 1 1 auto;
  font-size: 15px;
  padding: 5px 8px;
}
.compilar-control input[type=number] { width: 100%; max-width: 120px; }
.compilar-control select {
  width: 100%;
  min-width: 0;
  font-size: 15px;
  padding: 4px 6px;
}
.compilar-help {
  font-size: 15px;
  color: #8a8271;
  font-style: italic;
  max-width: 100%;
  margin-top: 1px;
}

/* path input con botón browse */
.compilar-path-input {
  flex: 1 1 150px;
  min-width: 0;
  max-width: 100%;
}
.compilar-browse { flex: 0 0 auto; }

/* radio group (target y emulador): grid de 3 columnas para compactar */
.compilar-radio-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 4px 10px;
  width: 100%;
}
.compilar-radio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 15px;
  color: #e8e3d5;
  cursor: pointer;
  line-height: 1.2;
}
.compilar-radio input[type=radio] { cursor: pointer; width: 14px; height: 14px; }
.compilar-radio span {
  font-family: 'VT323', ui-monospace, monospace;
  font-size: 15px;
}

/* color input */
.compilar-color-input {
  width: 40px;
  height: 30px;
  padding: 0;
  border: 2px solid #3f382a;
  background: #0c0a07;
  cursor: pointer;
  flex: 0 0 auto;
}
.compilar-color-txt {
  width: 110px !important;
  flex: 0 0 auto;
}

/* subgrupos de booleanos (4 columnas dentro para ahorrar espacio) */
.compilar-subgrupo {
  margin: 8px 0;
  padding: 6px 8px;
  border-left: 3px solid #ffd94a;
  background: #0c0a07;
}
.compilar-subgrupo-titulo {
  font-family: 'VT323', ui-monospace, monospace;
  font-size: 15px;
  color: #ffd94a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
  font-weight: bold;
}
.compilar-subgrupo-lista {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 4px 10px;
}

/* switch retro */
.compilar-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 15px;
  color: #e8e3d5;
  user-select: none;
}
.compilar-switch input { display: none; }
.compilar-switch-ui {
  width: 30px;
  height: 16px;
  background: #3f382a;
  border: 2px solid #4a4130;
  border-radius: 2px;
  position: relative;
  transition: background 0.1s;
  flex-shrink: 0;
}
.compilar-switch-ui::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 10px;
  height: 10px;
  background: #8a8271;
  transition: transform 0.1s, background 0.1s;
}
.compilar-switch input:checked + .compilar-switch-ui {
  background: #ffd94a;
  border-color: #ffd94a;
}
.compilar-switch input:checked + .compilar-switch-ui::after {
  transform: translateX(14px);
  background: #000;
}
.compilar-switch-label {
  font-family: 'VT323', ui-monospace, monospace;
  font-size: 15px;
  letter-spacing: 0.02em;
  line-height: 1.1;
}
.compilar-switch-inline .compilar-switch-label { color: #b5ac97; }

/* --- Salidas: cada bloque solo visible si está activo --- */
.compilar-salida-bloque {
  display: none;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.compilar-salida-bloque.activa { display: flex; }

.compilar-salida-cab {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.compilar-salida-titulo {
  font-family: 'VT323', ui-monospace, monospace;
  font-size: 18px;
  color: #ffd94a;
  letter-spacing: 0.04em;
}
.compilar-salida-help {
  font-size: 15px;
  color: #b5ac97;
}
.compilar-salida-botones {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}
.compilar-subtab.activa {
  border-color: #ffd94a;
  color: #ffd94a;
  background: #0e0c09;
}
.compilar-salida-pre {
  background: #0c0a07;
  color: #7dffab;
  padding: 10px;
  font-size: 15px;
  font-family: ui-monospace, Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-all;
  flex: 1 1 auto;
  overflow: auto;
  margin: 0;
  border: 1px solid #3f382a;
  line-height: 1.4;
  min-height: 0;
}

.compilar-salidas-vacio {
  color: #b5ac97;
  font-size: 18px;
  font-style: italic;
  text-align: center;
  padding: 32px 16px;
  font-family: 'VT323', ui-monospace, monospace;
}

/* ============================================================
   STATUS BAR (footer inferior)
   ============================================================ */
#status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: #0c0a07;
  border-top: 2px solid #3f382a;
  color: #8a8271;
  font-family: 'VT323', ui-monospace, monospace;
  font-size: 15px;
  flex: 0 0 auto;
  letter-spacing: 0.02em;
}
.status-item { color: #b5ac97; }
#status-version { color: #ffd94a; font-weight: bold; }
#status-proyecto { color: #e8e3d5; }
#status-escenas { color: #8a8271; }
#status-mensaje { color: #7dffab; }
.status-sep { color: #4a4130; }
.status-spacer { flex: 1 1 auto; }

/* ============================================================
   GESTOR DE IMÁGENES (js/imagenes.js)
   ============================================================ */
#dlg-imagenes { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; }
.imagenes-caja {
  position: relative;
  width: min(860px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  padding: 16px;
}
.imagenes-caja.soltar { outline: 2px dashed #ffd94a; outline-offset: -6px; }
.imagenes-barra { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.imagenes-tramado { font-size: 13px; color: #b5ac97; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.imagenes-total { margin-left: auto; font-size: 13px; color: #9a917d; }
.imagenes-ayuda { margin: 0 0 10px; font-size: 13px; color: #9a917d; }
.imagenes-ayuda code { color: #4dd8ff; }
.imagenes-lista {
  flex: 1 1 auto; overflow: auto; min-height: 120px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px;
  padding: 2px;
}
.imagenes-vacio { grid-column: 1 / -1; color: #9a917d; font-size: 14px; text-align: center; padding: 24px 8px; }
.imagen-tarjeta { background: #171310; border: 1px solid #3a322a; padding: 8px; display: flex; flex-direction: column; gap: 5px; }
.imagen-mini { width: 100%; aspect-ratio: 4 / 3; image-rendering: pixelated; background: #000; border: 1px solid #000; }
.imagen-fila { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.imagen-num { font-size: 13px; color: #ffd94a; display: flex; align-items: center; gap: 4px; }
.imagen-num input { width: 64px; padding: 2px 4px; font-size: 13px; }
.imagen-fichero { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: #4dff88; }
.imagen-info { font-size: 12px; color: #9a917d; }
.imagen-uso { font-size: 12px; color: #b5ac97; overflow-wrap: anywhere; }
.imagen-uso.sin-uso { color: #6f6656; font-style: italic; }
.imagen-botones { display: flex; gap: 6px; justify-content: flex-end; }

/* ============================================================
   MÓVIL Y PANTALLAS TÁCTILES
   ============================================================ */
/* los gestos sobre el lienzo y los separadores son del editor, no del navegador
   (sin esto el navegador desplaza/amplía la página y corta el arrastre) */
#grafo-viewport, .retro-splitter { touch-action: none; }

/* elementos solo para móvil: ocultos en escritorio */
#btn-menu, #nav-movil { display: none; }

@media (max-width: 767px) {
  /* dvh: descuenta la barra de direcciones del navegador móvil */
  #app { height: 100vh; height: 100dvh; }

  /* cabecera compacta: logo + título + ☰; la botonera se despliega debajo */
  #cabecera { position: relative; flex-wrap: nowrap; padding: 6px 8px; }
  #cabecera .subtitulo { display: none; }
  .titulo-juego { flex: 1 1 auto; width: auto; min-width: 0; max-width: none; }
  #btn-menu { display: inline-flex; flex: 0 0 auto; }
  .cabecera-derecha {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    padding: 8px; gap: 8px;
    background: #171310;
    border-bottom: 2px solid #3f382a;
    box-shadow: 0 6px 12px #000a;
  }
  #cabecera.menu-abierto .cabecera-derecha { display: flex; }
  .cabecera-derecha .sep-v { display: none; }

  /* un solo panel a pantalla completa, elegido con la barra inferior */
  #zona-trabajo, #panel-escena, #panel-herramientas,
  #splitter-x, #splitter-y, #btn-plegar, #status-bar { display: none; }
  #cuerpo[data-movil="grafo"] #zona-trabajo,
  #cuerpo[data-movil="escena"] #panel-escena,
  #cuerpo[data-movil="herramientas"] #panel-herramientas { display: flex; flex: 1 1 auto; height: auto; }
  #cuerpo.plegado #contenido-pestanas { display: block; }
  #panel-escena { overflow: auto; border-top: none; }

  /* las pestañas no caben: se desplazan en horizontal */
  #barra-pestanas { overflow-x: auto; }
  .pestana { flex: 0 0 auto; font-size: 13px; padding: 8px 10px; }

  #nav-movil {
    display: flex;
    flex: 0 0 auto;
    background: #171310;
    border-top: 2px solid #3f382a;
    padding-bottom: env(safe-area-inset-bottom);
  }
  #nav-movil button {
    flex: 1;
    padding: 12px 4px;
    background: transparent;
    border: none;
    color: #8a8271;
    font-family: ui-monospace, monospace;
    font-size: 22px;
    line-height: 1;
  }
  #nav-movil button.activa { color: #ffd94a; box-shadow: inset 0 3px 0 #ffd94a; }

  /* iOS amplía la página al enfocar campos de menos de 16 px */
  input, select, textarea, .retro-input { font-size: 16px; }
  .code-editor pre.code-layer,
  .code-editor textarea.code-layer { font-size: 16px; line-height: 24px; }

  /* Compilar: todo el panel se desplaza; cada bloque con su altura natural
     y las pestañas verticales pasan a una fila horizontal desplazable */
  .compilar-raiz { overflow: auto; }
  /* minmax(0, …) y min-width: 0: si no, la fila de pestañas ensancha la rejilla más que la pantalla */
  .compilar-cuerpo { flex: 0 0 auto; grid-template-columns: minmax(0, 1fr); }
  .compilar-bloque { flex-direction: column; overflow: visible; min-width: 0; }
  .compilar-vtabs {
    flex-direction: row; align-items: center;
    min-width: 0; overflow-x: auto;
    border-right: none; border-bottom: 2px solid #3f382a;
  }
  .compilar-vtab { border-left-width: 2px; border-bottom: 3px solid transparent; white-space: nowrap; }
  .compilar-vtab.activa { border-left-color: transparent; border-bottom-color: #ffd94a; }
  .compilar-vtab-generar { width: auto; margin: 0 6px 0 0; }
  .compilar-vcontenido { overflow: visible; }
  .compilar-salida-pre { max-height: 50vh; }
  .compilar-control .retro-input, .compilar-control select { font-size: 16px; }

  /* Simulador: la pantalla toma su alto del ancho (proporción NAT_W/NAT_H de simulador.js),
     no del hueco que dejan los controles: así no encoge al aparecer las opciones */
  .simulador { overflow-y: auto; }
  .sim-area { flex: 0 0 auto; aspect-ratio: 392 / 300; }

  /* Imágenes: dvh para que «Cerrar» no quede bajo la barra del navegador; menos margen */
  .imagenes-caja { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); padding: 12px; }
  .imagen-num input { font-size: 16px; }
}

/* dedo en vez de ratón: dianas más grandes */
@media (pointer: coarse) {
  .puerto::after { inset: -14px; }
  #grafo-controles button { width: 40px; height: 40px; font-size: 20px; }
  .retro-btn, .retro-mini { min-height: 36px; }
}
