/* Cáscara Botcito Web (W1-S1). La identidad de marca llega en W4; esto es
   deliberadamente sobrio. El CSS del editor viene aparte (editor.css, extraído
   del index.html de editor-web por el build). */

.screen {
  position: fixed;
  inset: 0;
}
.screen[data-active="false"] {
  visibility: hidden;
  pointer-events: none;
}

/* ---- Bienvenida (W4-S1, sobria) ---- */
#screen-welcome { background: #fff; }
.welcome-stage {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.welcome-logo { width: 41.25%; max-width: 720px; overflow: visible; }
/* Entrada: la cabeza desde la izquierda con rebote; letras en cascada. */
.welcome-logo .logo-head { transform: translateX(-300px); }
.welcome-logo.welcome-enter .logo-head {
  transition: transform .7s cubic-bezier(.34, 1.56, .64, 1);
  transform: none;
}
.welcome-logo .logo-letter { opacity: 0; transform: translateY(-14px); }
.welcome-logo.welcome-enter .logo-letter {
  transition: transform .38s cubic-bezier(.34, 1.56, .64, 1), opacity .3s ease-out;
  transform: none; opacity: 1;
}
/* OJO especificidad: la regla de arriba (3 clases) pone el shorthand
   `transition`, que RESETEA transition-delay a 0; estos retardos deben igualar
   esa especificidad (y van después) para ganar — con `.welcome-enter .logo-letter-N`
   a secas perdían y la cascada no se veía (bug de campo del cierre de W4-S1). */
.welcome-logo.welcome-enter .logo-letter-0 { transition-delay: .72s; }
.welcome-logo.welcome-enter .logo-letter-1 { transition-delay: .81s; }
.welcome-logo.welcome-enter .logo-letter-2 { transition-delay: .9s; }
.welcome-logo.welcome-enter .logo-letter-3 { transition-delay: .99s; }
.welcome-logo.welcome-enter .logo-letter-4 { transition-delay: 1.08s; }

/* ---- Menú hub (W4-S1) ---- */
#screen-menu { background: #FFF8EC; overflow: auto; font-family: system-ui, sans-serif; }
.menu-inner {
  min-height: 100%; box-sizing: border-box;
  display: flex; flex-direction: column; align-items: center;
  padding: 16px 24px 28px; gap: 4vh;
}
.menu-top { align-self: flex-end; }
.menu-logo { width: 41.25%; max-width: 560px; margin-top: 2vh; }
.menu-cards {
  display: grid; grid-template-columns: repeat(4, minmax(120px, 190px));
  gap: 16px; width: 100%; justify-content: center;
}
@media (max-width: 720px) { .menu-cards { grid-template-columns: repeat(2, minmax(130px, 1fr)); } }
.menu-card {
  position: relative; font: inherit;
  background: #fff; border: 2px solid #e8dfc9; border-radius: 18px;
  padding: 26px 12px 22px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  box-shadow: 0 2px 8px rgba(94, 74, 40, 0.12);
  transition: transform .12s ease, border-color .12s ease;
}
.menu-card[data-enabled="true"]:hover { transform: translateY(-3px); border-color: #4C97FF; }
.menu-card[data-enabled="false"] { opacity: .55; cursor: default; }
.menu-card-name { font-size: 1.15rem; font-weight: bold; color: #26323f; }
.menu-soon {
  font-size: .72rem; color: #7a8794;
  border: 1px solid #d6dde4; border-radius: 999px; padding: 2px 10px;
}
.projects-title-group { display: flex; align-items: center; gap: 10px; }

/* ---- Mini-carita de conexión (W4-S2: reemplaza a la pastilla) ---- */
.conn-face {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; background: none; cursor: pointer; padding: 4px;
  border-radius: 999px;
}
.conn-face:hover { background: rgba(76, 151, 255, 0.1); }
.conn-face-name {
  font-family: system-ui, sans-serif; font-size: .9rem; font-weight: bold;
  color: #26323f; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Replay del logo del menú (un toque = una entrada; lección de especificidad
   de S1: el pre-estado apaga las transiciones y el replay las enciende). */
.menu-logo { cursor: pointer; overflow: visible; }
.menu-logo.logo-pre .logo-head { transform: translateX(-300px); transition: none; }
.menu-logo.logo-pre .logo-letter { opacity: 0; transform: translateY(-14px); transition: none; }
.menu-logo.logo-replay .logo-head {
  transition: transform .7s cubic-bezier(.34, 1.56, .64, 1);
  transform: none;
}
.menu-logo.logo-replay .logo-letter {
  transition: transform .38s cubic-bezier(.34, 1.56, .64, 1), opacity .3s ease-out;
  transform: none; opacity: 1;
}
.menu-logo.logo-replay .logo-letter-0 { transition-delay: .72s; }
.menu-logo.logo-replay .logo-letter-1 { transition-delay: .81s; }
.menu-logo.logo-replay .logo-letter-2 { transition-delay: .9s; }
.menu-logo.logo-replay .logo-letter-3 { transition-delay: .99s; }
.menu-logo.logo-replay .logo-letter-4 { transition-delay: 1.08s; }

/* ---- Proyectos (provisoria en S1) ---- */
#screen-projects {
  background: #f7f9fb;
  overflow: auto;
  font-family: system-ui, sans-serif;
  color: #26323f;
}
.projects-inner { max-width: 640px; margin: 0 auto; padding: 24px 16px; }
.projects-header { display: flex; align-items: center; justify-content: space-between; }
.projects-header h1 { font-size: 1.4rem; margin: 0; }
.provisional-note { color: #7a8794; font-size: .85rem; margin: 6px 0 18px; }
.projects-actions { display: flex; gap: 8px; }
.primary-btn {
  font: inherit; font-size: .9rem; font-weight: bold;
  border: none; border-radius: 999px; cursor: pointer;
  background: #4C97FF; color: #fff; padding: 8px 16px;
}
.primary-btn:hover { background: #3d7fe0; }
.board-tabs { display: flex; gap: 6px; margin: 4px 0 14px; }
.board-tab {
  font: inherit; font-size: .85rem;
  border: 1px solid #d6dde4; border-radius: 999px;
  background: #fff; padding: 6px 14px; cursor: pointer;
}
.board-tab[data-active="true"] {
  background: #4C97FF; border-color: #4C97FF; color: #fff; font-weight: bold;
}
.projects-empty { color: #7a8794; white-space: pre-line; text-align: center; margin-top: 48px; font-size: 1.05rem; }
.project-card {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  background: #fff; border: 1px solid #e3e8ee; border-radius: 14px;
  padding: 14px 16px; cursor: pointer; width: 100%;
  font: inherit; text-align: left; margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(38, 50, 63, 0.06);
}
.project-card:hover { border-color: #4C97FF; }
.project-card .icon { font-size: 1.8rem; }
.project-card .text-col { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.project-card .name { font-weight: bold; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card .meta { color: #7a8794; font-size: .8rem; }
.gear-btn {
  font-size: 1.1rem; border: none; background: none; cursor: pointer;
  color: #7a8794; padding: 6px; border-radius: 50%;
}
.gear-btn:hover { background: #eef2f6; }
.card-menu {
  position: absolute; right: 10px; top: 46px; z-index: 5;
  background: #fff; border: 1px solid #d6dde4; border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .15);
  display: flex; flex-direction: column; min-width: 130px; overflow: hidden;
}
.card-menu button {
  font: inherit; font-size: .9rem; text-align: left;
  border: none; background: none; padding: 10px 14px; cursor: pointer;
}
.card-menu button:hover { background: #eef2f6; }

/* ---- Formulario crear/editar ---- */
.form-inner { max-width: 480px; margin: 0 auto; padding: 24px 16px; }
.form-inner h1 { font-size: 1.4rem; }
.form-label { display: block; font-weight: bold; font-size: .9rem; margin: 16px 0 6px; }
.form-input {
  font: inherit; font-size: 1rem; width: 100%; box-sizing: border-box;
  border: 1px solid #d6dde4; border-radius: 10px; padding: 10px 12px;
}
.form-input:focus { outline: 2px solid #4C97FF; border-color: #4C97FF; }
.icon-row { display: flex; align-items: center; gap: 12px; }
.icon-view { font-size: 2.4rem; }
.icon-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
  margin-top: 10px; background: #fff; border: 1px solid #e3e8ee;
  border-radius: 12px; padding: 8px;
}
.icon-cell { font-size: 1.5rem; border: none; background: none; cursor: pointer; border-radius: 8px; padding: 4px; }
.icon-cell:hover { background: #eef2f6; }
.board-fixed { color: #26323f; margin: 4px 0; }
.form-buttons { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.locale-btn {
  font: inherit; font-size: .85rem;
  border: 1px solid #d6dde4; border-radius: 999px;
  background: #fff; padding: 6px 14px; cursor: pointer;
}
.locale-btn:hover { border-color: #4C97FF; }

/* ---- Chrome del editor (geometría de la ronda 5: margen 12, alto 37) ---- */
#editor-chrome {
  position: absolute; top: 12px; left: 12px;
  display: flex; gap: 8px;
  /* Sobre el toolbox de Blockly (z-index 70) y bajo su UI de edición
     (widgetDiv 99 / dropDownDiv 100), que además oculta el chrome. */
  z-index: 80;
}
#editor-chrome[data-hidden="true"] { visibility: hidden; }
.circle-btn {
  width: 37px; height: 37px; border-radius: 50%;
  border: none; background: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  padding: 0;
}
.circle-btn:active { transform: scale(0.94); }
.circle-btn--44 { width: 44px; height: 44px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28); }

/* ---- Grupo de controles del lienzo (W1-S4, F8 ronda 3) ---- */
#editor-controls {
  position: absolute; bottom: 12px; left: 12px;
  display: flex; align-items: center; gap: 3px;
  z-index: 80; /* como #editor-chrome: sobre el toolbox, bajo la UI de edición */
}
#editor-controls[data-hidden="true"] { visibility: hidden; }
#controls-expansion {
  display: flex; align-items: center; gap: 3px;
  overflow: hidden; max-width: 0; opacity: 0;
  transition: max-width .35s ease, opacity .25s ease;
}
#editor-controls[data-expanded="true"] #controls-expansion {
  max-width: 260px; opacity: 1;
}
#toggle-icon { display: inline-flex; transition: transform .45s ease; }

/* ---- Estado de conexión (W2-S1) ---- */
#editor-conn {
  position: absolute; top: 12px; right: 12px; z-index: 80;
}
#editor-conn[data-hidden="true"] { visibility: hidden; }
.conn-pill {
  font: inherit; font-size: .9rem; font-weight: bold;
  height: 37px; border-radius: 999px; padding: 0 16px;
  border: 2px solid #9aa4af; background: #fff; color: #26323f;
  cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conn-pill[data-kind="resumable"] { border-color: #4C97FF; color: #2b6fd4; }
.conn-pill[data-kind="connecting"] { border-color: #4C97FF; color: #2b6fd4; }
.conn-pill[data-kind="reconnecting"] { border-color: #E08A12; color: #a9660a; }
.conn-pill[data-kind="connected"] { border-color: #3DD35C; color: #1d9e3c; }
.conn-pill[data-kind="lost"] { border-color: #FF3B30; color: #d0271e; }

/* ---- Pila de ejecución (W3-S1, F8-S4) ---- */
#editor-run {
  position: absolute; bottom: 12px; right: 12px; z-index: 80;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
#editor-run[data-hidden="true"] { visibility: hidden; }
.run-btn { position: relative; }
.run-btn[data-color="play"] { background: #3DD35C; }
.run-btn[data-color="stop"] { background: #FF3B30; }
.run-btn[data-color="console"] { background: #5CB1D6; }

/* ---- Banner de sincronización (W3-S3, F5-S2; top 64 como la app) ---- */
#sync-banner {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 70; /* sobre el monitor (60), bajo la UI de edición de Blockly */
  display: flex; align-items: center; gap: 12px;
  background: #dbe9ff; border: 1px solid #4C97FF; border-radius: 12px;
  padding: 10px 14px; font-family: system-ui, sans-serif; font-size: .92rem;
  color: #1d3a6b; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18); max-width: 90vw;
}
#sync-banner .primary-btn { padding: 6px 14px; }
.sync-x { border: none; background: none; cursor: pointer; color: #1d3a6b; font-size: .95rem; padding: 2px 4px; }

/* ---- MonitorCard (W3-S2, F8-S5) ---- */
#monitor-card {
  position: absolute; top: 50%; right: 66px;
  width: min(46%, 480px); height: 62%;
  margin-top: -31vh;
  background: #EAF2F8; border-radius: 14px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3);
  display: flex; flex-direction: column;
  font-family: system-ui, sans-serif; color: #26323f;
  z-index: 60; /* bajo el chrome (80) — el chrome sigue tocable, como la app */
  box-sizing: border-box; overflow: hidden;
}
.monitor-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; cursor: grab; user-select: none; touch-action: none;
}
.monitor-title { font-weight: bold; }
.monitor-x { border: none; background: none; font-size: 1rem; cursor: pointer; color: #26323f; padding: 2px 6px; }
.monitor-tabs { display: flex; align-items: center; gap: 6px; padding: 0 12px 8px; }
.monitor-tab {
  font: inherit; font-size: .82rem; border: 1px solid #c8d6e2; border-radius: 999px;
  background: #fff; padding: 4px 12px; cursor: pointer;
}
.monitor-tab[data-active="true"] { background: #4C97FF; border-color: #4C97FF; color: #fff; font-weight: bold; }
.monitor-clear { margin-left: auto; border: none; background: none; cursor: pointer; color: #575E75; padding: 4px; }
.monitor-list {
  flex: 1; overflow-y: auto; background: #fff; margin: 0 12px 12px;
  border-radius: 10px; padding: 8px 10px; font-size: .88rem;
}
.monitor-line { padding: 1px 0; font-family: ui-monospace, Consolas, monospace; }
.monitor-line[data-source="graph"] { color: #2b6fd4; }
.monitor-line[data-source="print"] { color: #7a8794; }
.monitor-empty { color: #7a8794; text-align: center; margin-top: 20px; }
.monitor-var { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid #f0f4f8; }
.var-name { font-weight: bold; }
.var-value { font-family: ui-monospace, Consolas, monospace; }
#play-ring {
  position: absolute; inset: 7px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.45); border-top-color: #fff;
  display: none;
}
#btn-play[data-busy="true"] #play-ring { display: block; animation: ring-spin .9s linear infinite; }
#btn-play[data-busy="true"] svg { visibility: hidden; }
@keyframes ring-spin { to { transform: rotate(360deg); } }

/* ---- Toast/aviso (W3-S1) ---- */
#toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 300; display: flex; align-items: center; gap: 12px;
  background: #26323f; color: #fff; border-radius: 12px;
  padding: 12px 16px; font-family: system-ui, sans-serif; font-size: .95rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35); max-width: 90vw;
}
#toast button {
  font: inherit; font-weight: bold; border: none; cursor: pointer;
  background: none; color: #7ab8ff; padding: 4px 6px;
}

/* ---- Hoja de robots (W2-S3, espejo del RobotSheet de la app) ---- */
#robot-sheet-overlay { position: fixed; inset: 0; z-index: 200; }
.sheet-catcher { position: absolute; inset: 0; }
.robot-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; height: 62%;
  box-sizing: border-box; overflow-y: auto;
  background: #FFF8EC; border-radius: 22px 22px 0 0;
  box-shadow: 0 -4px 22px rgba(0, 0, 0, 0.25);
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 16px; gap: 6px;
  font-family: system-ui, sans-serif; color: #26323f;
  animation: sheet-up .22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(30%); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-face { width: 120px; height: 120px; }
.sheet-title { font-size: 1.2rem; font-weight: bold; margin: 4px 0 0; }
.sheet-subtitle { color: #7a8794; margin: 0; min-height: 1.2em; }
.sheet-buttons { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
