/* ─── Panels & Editor base (mobile-first) ─── */
/* Base = mobile portrait (≤767px) */
#panels, #editor-panel {
  display: none;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  width: 100%;
  user-select: none;
}
#right-panels {
  display: none;
  flex-direction: row;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  width: 100%;
  user-select: none;
}
#right-panels > .sprout-panel {
  flex: 1;
  min-width: 0;
}
/* Estado "visible" de los wrappers de paneles (lo activa el JS via __setPanels
   con la clase, en vez de display inline, para que en el nivel FOR el CSS pueda
   usar display:contents y dejar que #queue-logica ocupe todo el ancho). */
#panels.panels-visible,
#right-panels.panels-visible {
  display: flex;
}
.panel {
  background: var(--bg-raised);
  border: 1px solid var(--border-dim);
  border-radius: var(--panel-radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#editor-panel {
  background: var(--bg-raised);
  border: 1px solid var(--border-dim);
  border-radius: var(--panel-radius);
  padding: 10px;
  display: none;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  /* width, max-height, overflow se definen en editor.css */
}
.panel h3, #editor-panel h3 {
  margin: 0 0 2px;
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
}

/* ─── Sprout Lands Panel (shared) ─── */
/* Base = mobile compact */
.sprout-panel {
  border: none;
  border-radius: 6px;
  width: 100%;
  padding: 6px 8px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  background:
    linear-gradient(170deg, #dfc99e 0%, #c8a87a 40%, #b89564 100%);
  background-color: #c8a87a;
  box-shadow:
    0 4px 20px rgba(0,0,0,.45),
    inset 0 1px 0 rgba(255,255,255,.25),
    inset 0 -1px 0 rgba(0,0,0,.1);
  transition: box-shadow var(--transition-slow);
  position: relative;
}
.sprout-panel::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 2px solid rgba(90,58,26,.18);
  border-radius: 4px;
  pointer-events: none;
}
.sprout-panel:hover {
  box-shadow:
    0 4px 28px rgba(0,0,0,.55),
    0 0 12px rgba(255,238,136,.04),
    inset 0 1px 0 rgba(255,255,255,.25),
    inset 0 -1px 0 rgba(0,0,0,.1);
}
/* Base = mobile compact titles */
.sprout-panel h3 {
  font-family: 'SproutPixel', monospace;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--sprout-mid);
  text-shadow: 0 1px 0 rgba(255,255,255,.3);
  margin: 0;
  display: block;
  height: auto;
  line-height: 1;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px 0;
  padding-bottom: 6px;
  border-bottom: 2px solid rgba(90,58,26,.15);
}
.panel-header h3 {
  margin: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.target-switch {
  display: flex;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(90,58,26,.35);
  flex-shrink: 0;
}
/* Base = mobile compact target options */
.target-opt {
  background: rgba(255,255,255,.2) !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 2px 5px !important;
  font-family: 'SproutPixel', monospace !important;
  font-size: 9px !important;
  font-weight: bold !important;
  color: rgba(90,58,26,.75) !important;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
  line-height: 1.2;
  min-height: 44px;
}
.target-opt.active {
  background: #f2c75a !important;
  color: #3b2308 !important;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.4);
}
.target-opt:hover:not(.active) {
  background: rgba(255,255,255,.4) !important;
}
#queue-func1 h3 { color: #4b688a; text-shadow: none; border-bottom-color: rgba(75,104,138,.2); }
#queue-for h3 { color: #7a4a12; text-shadow: none; border-bottom-color: rgba(122,74,18,.22); }
/* Base = mobile compact queue title */
#queue > h3 {
  margin: 0 0 2px 0;
  padding-bottom: 2px;
  font-size: 10px;
  border-bottom: 2px solid rgba(90,58,26,.15);
}
.desktop-only-switch {
  display: none;
}
/* ─── Direction & Queue buttons ─── */
.sprout-panel button {
  background: none !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 10px 8px !important;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sprout-dark);
  font: 600 12px ui-monospace, monospace;
  cursor: pointer;
  touch-action: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast), filter var(--transition-med);
  justify-content: flex-start;
}
#queue-for-content #clear-for {
  padding: 0 !important; 
}
.sprout-panel button:hover:not(:disabled) {
  opacity: .85;
  filter: brightness(1.08);
}
.sprout-panel button:active:not(:disabled) {
  transform: translateY(1px) scale(.97);
}
.sprout-panel button:disabled {
  opacity: .4;
  cursor: not-allowed;
  filter: grayscale(.4);
}

/* ─── Icons ─── */
.dir-icon, .queue-icon {
  width: 32px; height: 32px; flex-shrink: 0;
  background-image: url('../assets/SproutLands-UI/Sprite sheets/buttons/Small Square Buttons.png');
  background-size: 64px 256px;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--sprout-dark); line-height: 1;
  transition: filter var(--transition-fast);
}
.dir-icon { background-position: 0 -96px; }
.sprout-panel button:active:not(:disabled) .dir-icon { background-position: -32px -96px; }

/* ─── Slots (sprout panel) ─── */
/* Base = mobile compact slots */
.sprout-panel .slot {
  background: rgba(255,255,255,.2) !important;
  border: 2px dashed rgba(90,58,26,.25) !important;
  border-radius: 4px;
  color: rgba(90,58,26,.45);
  height: 28px !important;
  min-height: 28px;
  margin-bottom: 1px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-sizing: border-box;
  position: relative;
  transition: background var(--transition-med), border-color var(--transition-med), box-shadow var(--transition-med);
}
.sprout-panel .slot.filled {
  background: rgba(255,200,80,.3) !important;
  border-style: solid;
  border-color: rgba(90,58,26,.5);
  color: var(--sprout-mid);
  justify-content: space-between !important;
  padding: 0 8px;
  cursor: grab;
}
.sprout-panel .slot.filled:hover {
  box-shadow: inset 0 0 8px rgba(255,200,80,.15);
}
.sprout-panel .slot.filled:active { cursor: grabbing; }
.sprout-panel .slot.dragging { opacity: 0.5; outline: 2px dashed #4b8b3b; }
.sprout-panel .slot.drag-over {
  background: rgba(255,200,80,.45) !important;
  border-color: #a06020 !important;
  border-style: solid !important;
  box-shadow: inset 0 0 10px rgba(255,200,80,.15);
}

/* ─── Action icons ─── */
.run .queue-icon   { background-position: 0 -96px; color: #2a8a2a; font-size: 16px; font-weight: bold; }
.clear .queue-icon { background-position: 0 -32px; color: #cc2222; font-size: 16px; font-weight: bold; }
.run:active:not(:disabled) .queue-icon   { background-position: -32px -96px; }
.clear:active:not(:disabled) .queue-icon { background-position: -32px -32px; }
.run.running .queue-icon { opacity: .6; }
#restart .queue-icon { background-position: 0 -64px; color: var(--sprout-mid); font-size: 16px; font-weight: bold; }
#restart:active:not(:disabled) .queue-icon { background-position: -32px -64px; }

/* Base = mobile: labels hidden */
.dir-label {
  display: none;
  font-size: 14px;
  color: var(--sprout-dark);
  font-family: 'SproutPixel', monospace;
  text-transform: uppercase;
}
/* Base = mobile: queue labels hidden */
.queue-label {
  display: none;
  font-size: 14px;
  color: var(--sprout-dark);
  font-family: 'SproutPixel', monospace;
  text-transform: uppercase;
}
.slot.filled .dir-label {
  flex: 1;
  text-align: center;
}

/* ─── Generic panel / editor buttons ─── */
.panel button, #editor-panel button {
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  padding: 10px 10px;
  min-height: 36px;
  font: 600 12px ui-monospace, monospace;
  text-align: left;
  cursor: pointer;
  touch-action: none;
  transition: background var(--transition-fast), transform .05s ease, opacity var(--transition-med), border-color var(--transition-med);
}
.panel button:hover:not(:disabled), #editor-panel button:hover:not(:disabled) {
  background: #243049;
  border-color: #3d506e;
}
.panel button:active:not(:disabled), #editor-panel button:active:not(:disabled) {
  transform: translateY(1px) scale(.97);
}
.panel button:disabled, #editor-panel button:disabled {
  opacity: .4;
  cursor: not-allowed;
  filter: grayscale(.3);
}

/* ─── Slots container ─── */
.slots { display: flex; flex-direction: column; gap: 4px; }

/* Wrapper de botones de accion del Program: fila compacta (solo iconos) en mobile */
.queue-actions {
  display: flex;
  flex-direction: row;
  gap: 4px;
  margin-top: 2px;
}
.queue-actions > button {
  flex: 1;
  min-width: 0;
  min-height: 32px;
  padding: 2px !important;
  justify-content: center;
}
.slots.f1-slots { margin-bottom: 8px; gap: 6px; }

.slot {
  min-height: 44px; width: 100%; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; box-sizing: border-box;
  position: relative;
  transition: background var(--transition-med), border-color var(--transition-med);
}

/* Base Sprout Panel Slot (Main Program) */
.sprout-panel .slot {
  background: rgba(255,255,255,.2);
  border: 1px dashed rgba(90,58,26,.3);
  color: rgba(90,58,26,.45);
}

/* ─── D-pad #dirs: base = cruz clásica (mobile) ─── */
#dirs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-areas:
    "header header header"
    ".      up     ."
    "left   .      right"
    ".      down   ."
    "func1  func1  forbtn";
  gap: 1px;
  padding: 4px 6px;
}
#dirs .panel-header  { grid-area: header; margin-bottom: 2px; padding-bottom: 2px; }
#dirs button[data-dir="up"]    { grid-area: up; }
#dirs button[data-dir="down"]  { grid-area: down; }
#dirs button[data-dir="left"]  { grid-area: left; }
#dirs button[data-dir="right"] { grid-area: right; }
#dirs button[data-dir="func1"] { grid-area: func1; }
#dirs button[data-dir="for"]   { grid-area: forbtn; }
#dirs button[data-dir] {
  justify-content: center;
  min-height: 38px;
  padding: 2px !important;
}

/* ─── Panel de logica combinado (Funcion / For / Si) ─── */
/* Base (mobile/tablet): el wrapper .logica-stack se ve como 1 panel unificado
   con tabs (F1/FOR/SI). Los 3 .panel-plegable adentro son sólo contenedores
   de contenido: sin background ni border. Solo el panel del tab activo es
   visible. En desktop (>=1100px) se invierte: cada panel es un .sprout-panel
   independiente y colapsable, y el header con tabs se oculta. */
.logica-stack {
  background:
    linear-gradient(170deg, #dfc99e 0%, #c8a87a 40%, #b89564 100%);
  background-color: #c8a87a;
  border-radius: 6px;
  box-shadow:
    0 4px 20px rgba(0,0,0,.45),
    inset 0 1px 0 rgba(255,255,255,.25),
    inset 0 -1px 0 rgba(0,0,0,.1);
  position: relative;
  padding: 6px 8px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0;
  overflow: hidden;
  width: 100%;
}
.logica-stack::before {
  content: '';
  position: absolute;
  inset: 3px;
  border: 2px solid rgba(90,58,26,.18);
  border-radius: 4px;
  pointer-events: none;
}
.logica-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px 0;
  padding-bottom: 6px;
  border-bottom: 2px solid rgba(90,58,26,.15);
}
.logica-header h3 {
  color: var(--border-bright);
  margin: 0;
  padding-bottom: 0;
  border-bottom: none;
}
#queue-logica .logica-switch {
  flex-wrap: nowrap;
}
#queue-logica .logica-switch .logica-tab {
  flex: 1;
}
.logica-stack .panel-plegable {
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  width: 100%;
  position: static;
  overflow: visible;
}
.logica-stack .panel-plegable::before { display: none; }
.logica-stack .panel-plegable:hover { box-shadow: none; }
.logica-stack .panel-toggle { display: none; }
.logica-stack .panel-toggle-icon { display: none; }
.logica-stack .panel-plegable:not([data-activo-mobile="true"]) {
  display: none;
}
.logica-stack .panel-cuerpo {
  display: flex;
  flex-direction: column;
  gap: 0;
}
#queue-logica[data-activa="func1"] #logica-titulo { color: #4b688a; }
#queue-logica[data-activa="for"]   #logica-titulo { color: #7a4a12; }
#queue-logica[data-activa="if"]    #logica-titulo { color: #5a7f3a; }

/* ─── Sub-switch IF-1 / IF-2 dentro del panel SI ─── */
/* Base (mobile/tablet): visible y solo se muestra el if-block activo.
   En desktop (>=1100px) se oculta y se muestran ambos ifs. */
#queue-if-rule .if-tab-switch {
  margin-bottom: 6px;
  align-self: stretch;
}
.if-block {
  display: none;
  flex-direction: column;
}
.if-block.if-block-active {
  display: flex;
}
#queue-if-content[data-activa-if="if-1"] .if-rule-sep,
#queue-if-content[data-activa-if="if-2"] .if-rule-sep {
  display: none;
}

.target-opt[data-target="for"],
.sprout-panel button[data-dir="for"] {
  display: none;
}
.for-icon {
  color: #7a4a12;
  font-size: 10px;
  font-weight: 900;
}
.for-label {
  color: #7a4a12;
}
#queue-if-rock-left {
  display: none;
}
#queue-if-rock h3 {
  display: block;
  margin: 0 0 10px 0;
  height: auto;
  color: #5a7f3a;
  text-shadow: none;
  font-size: 16px;
  text-align: left;
}

/* ─── IF / FOR selects (unificado, sin duplicaciones) ─── */
.for-select-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.for-select-row .if-select-label {
  margin: 0;
  white-space: nowrap;
}
.for-select-row .if-select {
  margin-bottom: 0;
  flex: 1;
}
.if-select-label {
  font-size: 11px;
  color: rgba(90,58,26,.85);
  font-family: 'SproutPixel', monospace;
  text-transform: uppercase;
  margin: 2px 0 4px;
}
.if-select {
  width: 100%;
  min-height: 34px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background:
    linear-gradient(180deg, rgba(247,231,198,.7) 0%, rgba(222,191,143,.82) 100%),
    linear-gradient(45deg, transparent 50%, rgba(90,58,26,.75) 50%),
    linear-gradient(135deg, rgba(90,58,26,.75) 50%, transparent 50%);
  background-color: #d7b07b;
  background-repeat: no-repeat;
  background-position:
    0 0,
    calc(100% - 16px) 14px,
    calc(100% - 11px) 14px;
  background-size:
    100% 100%,
    5px 5px,
    5px 5px;
  border: 1px solid rgba(90,58,26,.42);
  border-radius: 4px;
  color: var(--sprout-dark);
  font-family: 'SproutPixel', monospace;
  font-size: 12px;
  padding: 6px 34px 6px 8px;
  box-sizing: border-box;
  margin-bottom: 8px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.28),
    inset 0 -1px 0 rgba(0,0,0,.08);
}
.if-select:focus {
  outline: none;
  border-color: rgba(90,58,26,.55);
  box-shadow: inset 0 0 0 1px rgba(255,200,80,.25);
}
.if-select option {
  background: #d3ae7a;
  color: #4a2e12;
}
.if-select option:checked {
  background: #b98b52;
  color: #2e1b09;
}
.if-select:disabled {
  opacity: .5;
}
.if-rule-sep {
  height: 1px;
  margin: 10px 0 2px;
  background: rgba(90,58,26,.28);
}
#queue-for h3 {
  display: block;
  margin: 0 0 10px 0;
  height: auto;
  color: #7a4a12;
  text-shadow: none;
  font-size: 16px;
  text-align: left;
}
#queue-if-rule h3 {
  display: block;
  margin: 0 0 10px 0;
  height: auto;
  color: #5a7f3a;
  text-shadow: none;
  font-size: 16px;
  text-align: left;
}

.var-label {
  font-size: 10px;
  color: rgba(90,58,26,0.5);
  font-family: 'SproutPixel', monospace;
  pointer-events: none;
  flex-shrink: 0;
}

.slot-trash-zone {
  position: fixed;
  width: 50px;
  height: 50px;
  background: #cc2222;
  color: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.1s;
  z-index: 9999;
  border: 2px solid #ff6666;
}
.slot-trash-zone.visible {
  opacity: 1;
  pointer-events: all;
  animation: popIn 0.2s ease-out;
}
.slot-trash-zone.drag-over {
  transform: scale(1.15) rotate(-5deg);
  background: #ff3333;
}
@keyframes popIn {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ─── Mission Box ─── */
#mission {
  background: #0d2544;
  border: 1px solid #2357a0;
  border-radius: 10px;
  padding: 10px 12px;
  display: none;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}
#mission h3 {
  margin: 0;
  font-size: 11px;
  color: #88ccff;
  text-transform: uppercase;
  font-family: ui-monospace, monospace;
}
#mission p {
  margin: 0;
  font-family: 'SproutPixel', monospace;
  font-size: 12px;
  color: #c0e0ff;
  line-height: 1.6;
}

/* ─── Tutorial del FOR: cuando el panel esta desplegado (auto-demo) el cartel
   centrado quedaria tapado por el panel FOR (que vive en la columna derecha
   en #right-panels). Lo corremos a la izquierda del centro para que se lea
   completo. ─── */
@keyframes icard-fade-in {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}
@keyframes icard-fade-out {
  from { opacity: 1; transform: translateY(0)    scale(1);   }
  to   { opacity: 0; transform: translateY(10px) scale(.96); }
}
/* Base = mobile: intro card ajustada para FOR */
body.for-open #intro-card {
  left: auto;
  right: 4px;
  bottom: 8%;
  transform: none;
  min-width: 0;
  max-width: 56vw;
  animation: icard-fade-in .25s ease both !important;
}
body.for-open #intro-card.icard-out {
  animation: icard-fade-out .2s ease forwards !important;
}

/* ─── Tooltip de advertencia de recursividad ─── */
.recursion-tooltip {
  position: fixed;
  transform: translateY(-50%);
  background: #f5e6c8;
  color: #4a2c0a;
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  line-height: 1.6;
  padding: 10px 14px;
  border-radius: 8px;
  border: 3px solid #c8a96e;
  width: max-content;
  max-width: 200px;
  white-space: normal;
  text-align: left;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.recursion-tooltip.tooltip-left {
  transform: translate(-100%, -50%);
  box-shadow: -2px 2px 0 #c8a96e;
}
.recursion-tooltip.tooltip-left::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translateY(-50%);
  border: 7px solid transparent;
  border-left-color: #c8a96e;
}
.recursion-tooltip.tooltip-left::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: #f5e6c8;
  margin-left: -1px;
}
.recursion-tooltip.tooltip-right {
  box-shadow: 2px 2px 0 #c8a96e;
}
.recursion-tooltip.tooltip-right::before {
  content: '';
  position: absolute;
  top: 50%;
  right: 100%;
  transform: translateY(-50%);
  border: 7px solid transparent;
  border-right-color: #c8a96e;
}
.recursion-tooltip.tooltip-right::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 100%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: #f5e6c8;
  margin-right: -1px;
}
.recursion-tooltip.visible {
  opacity: 1;
}

/* ─── Mobile landscape ─── */
@media (orientation: landscape) and (max-height: 500px) {
  .sprout-panel {
    padding: 6px 8px;
    gap: 1px;
  }
  #dirs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-areas:
      "header header header"
      ".      up     ."
      "left   .      right"
      ".      down   ."
      "func1  func1  forbtn";
    gap: 2px;
    padding: 4px 6px;
  }
  #dirs .panel-header { grid-area: header; margin-bottom: 2px; padding-bottom: 2px; }
  #dirs button[data-dir="up"]    { grid-area: up; }
  #dirs button[data-dir="down"]  { grid-area: down; }
  #dirs button[data-dir="left"]  { grid-area: left; }
  #dirs button[data-dir="right"] { grid-area: right; }
  #dirs button[data-dir="func1"] { grid-area: func1; }
  #dirs button[data-dir="for"]   { grid-area: forbtn; }
  #dirs button[data-dir] {
    justify-content: center;
    min-height: 36px;
    padding: 2px !important;
  }
  .sprout-panel .slot {
    height: 24px !important;
    min-height: 24px;
  }
  .queue-actions > button {
    min-height: 28px;
  }
}

/* ─── Tablet (≥768px) ─── */
@media (min-width: 768px) {
  #right-panels {
    flex-direction: column;
  }
  .logica-stack {
    flex: none;
  }
  .sprout-panel {
    width: 100%;
    padding: 14px 16px;
    gap: 2px;
  }
  .sprout-panel h3 {
    font-size: 14px;
  }
  .target-opt {
    padding: 3px 8px !important;
    font-size: 10px !important;
  }
  #queue > h3 {
    margin: 0 0 10px 0;
    padding-bottom: 6px;
    font-size: 14px;
  }
  /* D-pad: grilla vertical en tablet con f1/for apilados horizontalmente */
  #dirs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "header header"
      "up     down"
      "left   right"
      "func1  forbtn";
    gap: 2px;
    padding: 14px 16px;
  }
  #dirs .panel-header { margin-bottom: 10px; padding-bottom: 6px; }
  #dirs button[data-dir] {
    justify-content: flex-start;
    min-height: 44px;
    padding: 10px 8px !important;
  }
  /* Labels hidden en tablet para la grilla compacta */
  .dir-label {
    display: none;
  }
  /* Slots restaurados */
  .sprout-panel .slot {
    height: 34px !important;
    min-height: 34px;
    margin-bottom: 4px;
  }
  /* Queue actions: display contents (columna) */
  .queue-actions {
    /* display: contents; */
    /* flex-direction: column; */
  }
  /* Intro card FOR: no necesita override en tablet+ */
  body.for-open #intro-card {
    left: 50%;
    right: auto;
    bottom: 20px;
    transform: translateX(-50%);
    min-width: auto;
    max-width: none;
  }
}

/* ─── Desktop (≥1100px): tamaños originales ─── */
@media (min-width: 1100px) {
  /* En desktop volvemos a mostrar la lista vertical de botones de direccion */
  #dirs {
    display: flex;
    flex-direction: column;
  }
  .desktop-only-switch {
    display: flex;
  }
  .target-opt {
    padding: 6px 12px !important;
    font-size: 13px !important;
  }
  .queue-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "run clear"
      "restart restart";
    gap: 4px;
  }
  .queue-actions #run { grid-area: run; }
  .queue-actions #clear { grid-area: clear; }
  .queue-actions #restart { grid-area: restart; }

  .if-rule-sep { display: block; }
  #panels, #right-panels, #editor-panel {
    /* min-width: 220px;
    width: auto; */
    flex-grow: 0;
    flex-basis: 220px;
  }
  .queue-label {
    display: inline;
  }
  .dir-label {
    display: inline;
  }
  .sprout-panel {
    /* width: 200px; */
  }
  .sprout-panel button {
    padding: 4px 2px !important;
    min-height: auto;
  }
  .panel button, #editor-panel button {
    padding: 8px 10px;
    min-height: auto;
  }
  .slot {
    min-height: 32px;
  }
  .sprout-panel .slot {
    height: 34px !important;
  }
  #mission {
    width: 200px;
  }
  /* Desktop: ocultar el sub-switch IF-1/IF-2 y mostrar ambos ifs + separador. */
  #queue-if-rule .if-tab-switch {
    display: none;
  }
  .if-block {
    display: flex;
  }
  #queue-if-rule .if-rule-sep {
    display: block;
  }

  /* ─── Desktop: acordeon de paneles colapsables ─── */
  /* En desktop el .logica-stack deja de ser un panel unificado: cada
     .panel-plegable es un .sprout-panel independiente con su boton colapsar.
     El header con tabs (F1/FOR/SI) se oculta, y el sub-switch IF-1/IF-2
     tambien (los dos ifs se muestran siempre apilados). */
  .logica-stack {
    background: none;
    border-radius: 0;
    box-shadow: none;
    /* width: 200px; */
    padding: 0;
    gap: 12px;
    overflow: visible;
  }
  .logica-stack::before { display: none; }
  .logica-header { display: none; }
  /* El :not([data-activo-mobile="true"]) en la regla base tiene specificity
     (0,3,0).  Repetirlo aquí sube el override a (0,3,1) y gana en desktop. */
  body .logica-stack .panel-plegable,
  body .logica-stack .panel-plegable:not([data-activo-mobile="true"]) {
    display: flex;
    background:
      linear-gradient(170deg, #dfc99e 0%, #c8a87a 40%, #b89564 100%);
    background-color: #c8a87a;
    border: none;
    border-radius: 6px;
    box-shadow:
      0 4px 20px rgba(0,0,0,.45),
      inset 0 1px 0 rgba(255,255,255,.25),
      inset 0 -1px 0 rgba(0,0,0,.1);
    padding: 6px 8px;
    width: 100%;
    position: relative;
    overflow: hidden;
    display: flex;
  }
  .logica-stack .panel-plegable::before {
    content: '';
    position: absolute;
    inset: 3px;
    border: 2px solid rgba(90,58,26,.18);
    border-radius: 4px;
    pointer-events: none;
    display: block;
  }
  .logica-stack .panel-toggle {
    display: flex;
    width: 100%;
    min-height: 28px;
    justify-content: space-between !important;
    gap: 8px !important;
    padding: 0 0 8px !important;
    font-family: 'SproutPixel', monospace !important;
    font-size: 16px !important;
    text-transform: uppercase;
    line-height: 1;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
  }
  #queue .panel-toggle {
    border-bottom: 1px solid rgba(90,58,26,.22);
  }
  #queue-func1 .panel-toggle {
    color: #4b688a !important;
    border-bottom: 1px solid rgba(75,104,138,.2);
  }
  #queue-for .panel-toggle {
    color: #7a4a12 !important;
    border-bottom: 1px solid rgba(122,74,18,.22);
  }
  #queue-if-rule .panel-toggle {
    color: #5a7f3a !important;
    border-bottom: 1px solid rgba(90,127,58,.22);
  }
  .logica-stack .panel-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: rgba(90,58,26,.76);
    transition: transform .16s ease;
  }
  .logica-stack .panel-cuerpo {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 600px;
    opacity: 1;
    transition: max-height .18s ease, opacity .14s ease;
    margin-top: 6px;
  }
  .logica-stack .panel-plegable.plegado .panel-cuerpo {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
  }
  .logica-stack .panel-plegable.plegado .panel-toggle {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
    border-bottom-color: transparent !important;
  }
  .logica-stack .panel-plegable.plegado .panel-toggle-icon {
    transform: rotate(-90deg);
  }
  /* En desktop los 3 paneles siempre son visibles (plegados o desplegados);
     la disponibilidad solo rige en mobile/tablet via tabs. */
}
