/* CodeUltraCool — UI del candidato. Tema oscuro, enfocado, profesional. */
:root {
  --bg: #0b0e14;
  --bg-1: #11151f;
  --bg-2: #171c28;
  --bg-3: #1e2536;
  --border: #262e42;
  --border-2: #333d57;
  --text: #e6e9f0;
  --text-dim: #9aa4bd;
  --text-faint: #6b7590;
  --brand: #5b8cff;
  --brand-2: #7aa2ff;
  --ok: #30a46c;
  --ok-dim: #1c6e46;
  --warn: #f5a623;
  --danger: #e5484d;
  --purple: #8b5cf6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', ui-monospace, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #16203a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
#app { min-height: 100%; }
h1, h2, h3 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -0.01em; }
a { color: var(--brand-2); }
button { font-family: inherit; }

/* --- Botones --- */
.btn {
  appearance: none; border: 1px solid var(--border-2); background: var(--bg-3); color: var(--text);
  padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 550;
  cursor: pointer; transition: .15s; display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: var(--bg-2); border-color: var(--brand); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, var(--brand-2), var(--brand)); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(180deg, var(--brand-2), var(--brand)); }
.btn-ok { background: var(--ok); border-color: transparent; color: #fff; }
.btn-ok:hover { filter: brightness(1.08); background: var(--ok); }
.btn-ghost { background: transparent; }
.btn-lg { padding: 14px 26px; font-size: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn.active { border-color: var(--brand); color: var(--text); background: var(--bg-3); }

/* --- Centrado de pantallas --- */
.screen-center { min-height: 100vh; display: grid; place-items: center; padding: 32px; }
.card {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.access-card { width: min(560px, 100%); padding: 40px; }
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.brand-logo { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--purple)); display: grid; place-items: center; font-size: 22px; }
.brand-name { font-size: 20px; font-weight: 700; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.field { margin: 16px 0; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.input {
  width: 100%; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); color: var(--text); font-size: 15px; outline: none; transition: .15s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91, 140, 255, .18); }
.rules { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin: 20px 0; }
.rules li { margin: 8px 0; color: var(--text-dim); font-size: 14px; }
.error-text { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 18px; }

/* --- Barra superior del examen --- */
/* Shell del examen: columna de altura fija. El topbar toma su altura natural y
   #stageHost ocupa TODO el resto → la página nunca scrollea (solo los paneles
   internos: chat, editor, salida, o el propio stageHost en etapas no-código). */
body.exam-mode { overflow: hidden; }
.exam-shell { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
#stageHost { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; }
/* La etapa de código es una columna: barra de problemas (altura propia) +
   coding-layout que ocupa TODO el resto. Sin esto, la barra de pestañas empuja
   el layout y desborda #stageHost justo por su altura. */
.coding-host { height: 100%; min-height: 0; display: flex; flex-direction: column; }

.topbar {
  flex: none; z-index: 40; height: 56px; display: flex; align-items: center; gap: 16px;
  padding: 0 20px; background: rgba(11, 14, 20, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand-name { font-size: 15px; }
.stages-progress { display: flex; gap: 6px; align-items: center; margin-left: 8px; }
.stage-dot { width: 26px; height: 6px; border-radius: 3px; background: var(--bg-3); }
.stage-dot.done { background: var(--ok); }
.stage-dot.active { background: var(--brand); }
.spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12.5px; background: var(--bg-3); border: 1px solid var(--border); color: var(--text-dim); }
.pill.rec { color: var(--danger); }
.pill.rec .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.timer { font-family: var(--mono); font-size: 14px; color: var(--text); }
.timer.warn { color: var(--warn); }
.timer.danger { color: var(--danger); }

/* --- Contenedor de etapa --- */
.stage-wrap { max-width: 1400px; margin: 0 auto; padding: 24px 20px 40px; }
.stage-intro { max-width: 1080px; margin: 4vh auto; text-align: center; }
.stage-intro .kicker { color: var(--brand-2); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; font-size: 15px; }
.stage-intro h1 { font-size: 40px; margin-top: 10px; line-height: 1.15; }
/* Las instrucciones son lo primero que se lee y no hay segunda oportunidad de
   entenderlas: texto grande, claro y con las palabras clave resaltadas. */
.stage-intro .intro-text { max-width: 780px; margin: 0 auto; }
.stage-intro .intro-text p { color: var(--text); font-size: 20px; line-height: 1.65; margin: 14px 0; }
.stage-intro .intro-text strong { color: #fff; font-weight: 750; }
.stage-intro p { color: var(--text-dim); font-size: 16px; }

/* --- Ejemplo gráfico en la pantalla de instrucciones --- */
.stage-demo { margin: 30px 0 8px; padding: 22px 20px 18px; background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius); }
.demo-label { color: var(--brand-2); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 18px; }
/* La columna del centro va más ancha: la ecuación es monoespaciada y no debe
   partirse en dos líneas (en el juego real siempre se lee de un vistazo). */
.demo-steps { display: grid; grid-template-columns: 1fr auto 1.4fr auto 1fr; gap: 10px; align-items: stretch; }
.demo-step { min-width: 0; display: flex; flex-direction: column; padding: 16px 14px; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius-sm); }
.demo-step-head { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; font-weight: 700; margin-bottom: 12px; }
.demo-num { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 13px; display: grid; place-items: center; }
.demo-body { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 150px; }
.demo-foot { color: var(--text-dim); font-size: 13.5px; line-height: 1.45; margin-top: 12px; }
.demo-arrow { align-self: center; color: var(--text-faint); font-size: 22px; }
.demo-hint { color: var(--text-faint); font-size: 12.5px; margin-top: 10px; }
.demo-repeat { color: var(--text-dim); font-size: 14px; margin-top: 16px; }
.demo-note { font-size: 14px; line-height: 1.4; margin-top: 12px; min-height: 40px; color: var(--text-faint); }
.demo-note.good { color: var(--ok); }
.demo-note.bad { color: var(--danger); }
/* El ejemplo reutiliza las clases del juego real (.eq-display, .stroop-word…)
   para verse idéntico, pero a menor escala. Esos ajustes van SIEMPRE anidados
   bajo .stage-demo: las reglas del juego viven más abajo en este archivo y, a
   igual especificidad, ganarían por orden. */
/* Ejemplo del juego de ecuaciones. */
.stage-demo .demo-icon { width: 74px; height: 74px; }
.stage-demo .demo-timer { width: 120px; height: 5px; margin-top: 14px; }
.stage-demo .demo-timer .span-timer-fill { animation: span-drain 3.1s linear infinite; }
.stage-demo .demo-eq { font-size: 26px; white-space: nowrap; letter-spacing: -.03em; margin: 0 0 16px; }
.stage-demo .demo-tf { gap: 8px; min-height: 44px; align-items: center; }
.stage-demo .demo-tf .btn { min-width: 0; font-size: 14px; padding: 9px 13px; }
.demo-verdict { font-size: 30px; line-height: 1; }
.demo-verdict.good { color: var(--ok); }
.demo-verdict.bad { color: var(--danger); }
.demo-slots { display: flex; gap: 8px; justify-content: center; }
.demo-slots .icon-chip { cursor: default; width: 54px; height: 54px; }
.demo-slots .icon-chip:hover { border-color: var(--border-2); transform: none; }
/* Ejemplo del Stroop. */
.demo-stroop { max-width: 460px; margin: 0 auto; }
.stage-demo .demo-word { font-size: 62px; margin: 12px 0 24px; }
.stage-demo .demo-stroop-options { grid-template-columns: repeat(2, minmax(120px, 170px)); gap: 10px; }
.stage-demo .demo-stroop-options .stroop-opt { font-size: 20px; padding: 13px; }
.stage-demo .stroop-opt.demo-right { border-color: var(--ok); background: rgba(48,164,108,.14); }
.stage-demo .stroop-opt.demo-wrong { border-color: var(--danger); background: rgba(229,72,77,.12); }
.stage-demo .stroop-opt.demo-faded { opacity: .4; }

/* --- Juego: ecuaciones --- */
.game { max-width: 720px; margin: 4vh auto; text-align: center; }
.game-progress { color: var(--text-faint); font-size: 13px; margin-bottom: 24px; letter-spacing: .04em; }
.eq-icon { font-size: 84px; line-height: 1; margin: 10px 0 4px; filter: drop-shadow(0 6px 20px rgba(0,0,0,.4)); }
.eq-display { font-family: var(--mono); font-size: 40px; font-weight: 600; margin: 18px 0 30px; }
.tf-buttons { display: flex; gap: 16px; justify-content: center; }
.tf-buttons .btn { min-width: 150px; justify-content: center; font-size: 17px; padding: 16px; }
.btn-true { border-color: var(--ok-dim); }
.btn-true:hover { background: rgba(48,164,108,.15); border-color: var(--ok); }
.btn-false:hover { background: rgba(229,72,77,.12); border-color: var(--danger); }

/* --- Recall de orden de íconos --- */
.recall { max-width: 820px; margin: 5vh auto; text-align: center; }
.recall-slots { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; min-height: 76px; padding: 14px; background: var(--bg); border: 1px dashed var(--border-2); border-radius: var(--radius); margin: 18px 0; }
.recall-pool { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 18px 0; }
.icon-chip { font-size: 34px; width: 62px; height: 62px; display: grid; place-items: center; background: var(--bg-3); border: 1px solid var(--border-2); border-radius: 12px; cursor: pointer; transition: .12s; user-select: none; }
.icon-chip:hover { border-color: var(--brand); transform: translateY(-2px); }
.icon-chip.placed { opacity: .25; pointer-events: none; }
.slot-index { position: relative; }
.slot-index::after { content: attr(data-i); position: absolute; top: -8px; left: -8px; font-size: 11px; background: var(--brand); color: #fff; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; }

/* --- Juego: memoria de secuencia (span) --- */
.span-game { max-width: 860px; margin: 0 auto; }
.span-stage { text-align: center; padding: 3vh 0 1vh; }
.span-hud { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border-2); margin-bottom: 8px; }
.span-hud-spacer { flex: 1; }
.span-level-badge { font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.span-best { color: var(--text-faint); font-size: 13px; }
.span-lives { display: flex; gap: 4px; font-size: 20px; line-height: 1; }
.span-lives .life { color: var(--danger); }
.span-lives .life.lost { color: var(--border-2); }
/* Íconos SVG monocromáticos: heredan el color del texto. */
.span-icon { color: var(--text); display: inline-grid; place-items: center; }
.span-icon.big { width: 132px; height: 132px; margin: 8px auto 6px; filter: drop-shadow(0 6px 20px rgba(0,0,0,.35)); animation: span-pop .18s ease-out; }
@keyframes span-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.span-timer { width: 220px; height: 6px; margin: 22px auto 0; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.span-timer-fill { height: 100%; width: 100%; background: var(--brand); transform-origin: left; animation: span-drain linear forwards; }
@keyframes span-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.span-feedback { font-size: 96px; line-height: 1; margin: 8px 0; animation: span-pop .18s ease-out; }
.span-feedback.good { color: var(--ok); }
.span-feedback.bad { color: var(--danger); }
.span-feedback.timeout { color: var(--warn); }
.span-chip svg { width: 34px; height: 34px; }
.span-banner { max-width: 620px; margin: 6vh auto; text-align: center; padding: 30px; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--radius); }
.span-banner.good { border-color: var(--ok); }
.span-banner.bad { border-color: var(--danger); }
.span-banner-icon { font-size: 60px; line-height: 1; margin-bottom: 8px; }
.span-banner.good .span-banner-icon { color: var(--ok); }
.span-banner.bad .span-banner-icon { color: var(--danger); }
.seq-compare { display: grid; gap: 8px; max-width: 520px; margin: 0 auto; }
.seq-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.seq-row .lbl { width: 40px; color: var(--text-faint); font-size: 12px; text-align: right; }
.seq-icon { color: var(--text); width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; background: var(--bg-3); }
.seq-icon svg { width: 24px; height: 24px; }
.seq-icon.good { outline: 2px solid var(--ok); }
.seq-icon.bad { outline: 2px solid var(--danger); }

/* --- Juego: Stroop --- */
.stroop-word { font-size: 76px; font-weight: 800; margin: 20px 0 34px; letter-spacing: -.02em; }
.stroop-options { display: grid; grid-template-columns: repeat(2, minmax(140px, 200px)); gap: 14px; justify-content: center; }
.stroop-opt { font-size: 26px; font-weight: 800; padding: 20px; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 12px; cursor: pointer; transition: .12s; }
.stroop-opt:hover { border-color: var(--brand); transform: translateY(-2px); background: var(--bg-3); }
.stroop-timerbar { height: 5px; background: var(--bg-3); border-radius: 3px; overflow: hidden; max-width: 430px; margin: 0 auto 30px; }
.stroop-timerbar > i { display: block; height: 100%; background: var(--brand); transition: width .1s linear; }

/* --- Etapa de código --- */
/* height fija + overflow:hidden: el layout NUNCA crece la página; cada panel
   hace su propio scroll interno (clave: min-height:0 en los hijos flex/grid). */
.coding-layout { display: grid; grid-template-columns: 380px 1fr; gap: 0; flex: 1 1 auto; min-height: 0; overflow: hidden; }
.coding-layout.with-ai { grid-template-columns: 340px 1fr 380px; }
.coding-layout > * { min-height: 0; min-width: 0; }
.panel { overflow: auto; border-right: 1px solid var(--border); }
.statement-panel { padding: 22px; background: var(--bg-1); }
.statement-panel h1, .statement-panel h2, .statement-panel h3 { line-height: 1.3; }
.statement-panel pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; }
.statement-panel code { font-family: var(--mono); font-size: 13px; }
.statement-panel :not(pre) > code { background: var(--bg-3); padding: 1px 6px; border-radius: 5px; }
.problem-tabs { flex: none; display: flex; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--bg-1); overflow-x: auto; }
.problem-tab { padding: 7px 12px; border-radius: 8px; font-size: 13px; cursor: pointer; color: var(--text-dim); white-space: nowrap; border: 1px solid transparent; }
.problem-tab.active { background: var(--bg-3); color: var(--text); border-color: var(--border-2); }
.problem-tab .badge { margin-left: 6px; }
.tests-list { margin-top: 18px; }
.tests-list .t { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; margin-bottom: 6px; font-size: 13px; color: var(--text-dim); }

.editor-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: #0d1017; }
/* Pestañas de vista (Código / Asistente) dentro de la columna del editor. */
.view-tabs { display: flex; gap: 6px; padding: 8px 12px 0; border-bottom: 1px solid var(--border); background: var(--bg-1); }
.view-tab { padding: 8px 16px; border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0; font-size: 13px; cursor: pointer; color: var(--text-dim); background: transparent; }
.view-tab:hover { color: var(--text); }
.view-tab.active { background: #0d1017; color: var(--text); border-color: var(--border); margin-bottom: -1px; }
/* Vista de código y vista de chat "amplio": ambas ocupan el resto de la columna. */
.code-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-wide { flex: 1; min-height: 0; display: none; flex-direction: column; }
.chat-wide .ai-panel { border-left: none; }
.chat-side { min-height: 0; min-width: 0; overflow: hidden; }
.editor-toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg-1); }
.file-tab { font-family: var(--mono); font-size: 13px; color: var(--text-dim); padding: 4px 10px; background: var(--bg-3); border-radius: 6px; }
.file-bar { flex: none; display: flex; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg-1); overflow-x: auto; }
.file-chip { font-family: var(--mono); font-size: 12.5px; padding: 5px 10px; border-radius: 6px; cursor: pointer; color: var(--text-dim); white-space: nowrap; border: 1px solid transparent; background: var(--bg-2); }
.file-chip:hover { border-color: var(--border-2); color: var(--text); }
.file-chip.active { background: var(--bg-3); color: var(--text); border-color: var(--brand); }
.file-chip.readonly { opacity: 0.7; font-style: italic; }
.lang-select { margin-left: 8px; padding: 5px 8px; background: var(--bg-3); color: var(--text); border: 1px solid var(--border-2); border-radius: 6px; font-size: 13px; font-family: inherit; cursor: pointer; outline: none; }
.lang-select:hover { border-color: var(--brand); }
#monaco { flex: 1; min-height: 0; }
.output { height: 210px; flex: none; border-top: 1px solid var(--border); background: var(--bg); display: flex; flex-direction: column; }
.output-resizer { flex: none; height: 8px; cursor: row-resize; background: var(--bg-1); border-top: 1px solid var(--border); touch-action: none; }
.output-resizer::after { content: ''; display: block; width: 40px; height: 3px; margin: 2px auto 0; border-radius: 2px; background: var(--border-2); }
.output-resizer:hover { background: var(--brand); }
.output-resizer:hover::after { background: #fff; }
.output-head { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--text-faint); }
.output-body { flex: 1; overflow: auto; padding: 10px 14px; font-family: var(--mono); font-size: 13px; white-space: pre-wrap; }
.case { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.case .ico { flex-shrink: 0; }
.case.pass .name { color: var(--text); }
.case.fail .name, .case.error .name { color: var(--text); }
.case .msg { color: var(--danger); font-size: 12px; }
.logs-block { margin-top: 12px; border-top: 1px dashed var(--border-2); padding-top: 8px; }
.logs-head { font-size: 11.5px; color: var(--text-dim); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em; }
.logs-pre { margin: 0; padding: 8px 10px; background: var(--bg-1); border: 1px solid var(--border); border-radius: 6px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; overflow-x: auto; max-height: 60vh; overflow-y: auto; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.ok { background: rgba(48,164,108,.16); color: #4ade80; }
.badge.bad { background: rgba(229,72,77,.16); color: #ff7b7b; }
.badge.neutral { background: var(--bg-3); color: var(--text-dim); }

/* --- Panel de IA --- */
.ai-panel { display: flex; flex-direction: column; min-height: 0; background: var(--bg-1); border-left: 1px solid var(--border); height: 100%; }
.ai-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex: none; }
.ai-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
/* min-height:0 → el área de mensajes se encoge y hace scroll interno (no crece la página). */
.ai-messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.ai-input { flex: none; }
/* En vista amplia, centra la conversación y limita el ancho de línea para legibilidad. */
.chat-wide .ai-messages { align-items: stretch; }
.chat-wide .msg { max-width: 760px; width: fit-content; }
.chat-wide .msg.assistant { align-self: flex-start; }
.chat-wide .msg.user { align-self: flex-end; }
.msg { max-width: 92%; padding: 10px 13px; border-radius: 12px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--bg-3); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.assistant pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; overflow-x: auto; }
.msg.assistant code { font-family: var(--mono); font-size: 12.5px; }
.msg.assistant :not(pre) > code { background: var(--bg-2); padding: 1px 5px; border-radius: 4px; }
.ai-input { padding: 12px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.ai-input textarea { flex: 1; resize: none; height: 44px; max-height: 140px; padding: 11px 13px; background: var(--bg); border: 1px solid var(--border-2); border-radius: 10px; color: var(--text); font-family: inherit; font-size: 14px; outline: none; }
.ai-input textarea:focus { border-color: var(--brand); }
.ai-empty { color: var(--text-faint); text-align: center; margin: auto; font-size: 13.5px; max-width: 240px; }

/* --- Barra de acciones inferior de etapa --- */
.stage-actions { display: flex; justify-content: center; gap: 12px; margin-top: 34px; }
.coding-nextbar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-top: 1px solid var(--border); background: var(--bg-1); }

/* --- Pantalla final --- */
.finish { max-width: 620px; margin: 12vh auto; text-align: center; padding: 40px; }
.finish .check { font-size: 64px; }
.score-ring { font-size: 46px; font-weight: 800; margin: 10px 0; }

.spinner { width: 16px; height: 16px; border: 2px solid var(--border-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Overlay de guardia (fuera de fullscreen) --- */
.guard-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(6,8,12,.92); backdrop-filter: blur(8px); display: grid; place-items: center; }
/* CRÍTICO: el atributo `hidden` debe ganarle a `display: grid` de arriba; si no, el
   overlay se ve SIEMPRE desde el primer render y el botón nunca lo puede ocultar. */
.guard-overlay[hidden] { display: none !important; }
.guard-card { text-align: center; max-width: 460px; padding: 40px; }
.guard-icon { font-size: 54px; }
.blurred { filter: blur(7px); pointer-events: none; user-select: none; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); background-clip: padding-box; }

@media (max-width: 900px) {
  .coding-layout, .coding-layout.with-ai { grid-template-columns: 1fr; height: auto; }
  .stroop-options { grid-template-columns: 1fr 1fr; }
  /* El storyboard del ejemplo pasa de 3 columnas a una pila vertical. */
  .stage-intro h1 { font-size: 30px; }
  .stage-intro .intro-text p { font-size: 17.5px; }
  .demo-steps { grid-template-columns: 1fr; }
  .demo-arrow { transform: rotate(90deg); }
  .demo-body { min-height: 0; }
  .stage-demo .demo-word { font-size: 46px; }
  .stage-demo .demo-eq { font-size: 24px; }
}
