/* ===================== IDE de Python del simulador (estilo VS Code) ===================== */
.sim-mission.is-ide { grid-template-columns: minmax(0, 1.45fr) minmax(340px, 1fr); align-items: start; }
.ide { --ide-bg: #111a31; --ide-side: #0e162b; --ide-bar: #0b1226; --ide-line: #1f2b4d; --ide-text: #d8e0f7; --ide-muted: #7b88b0;
    display: flex; flex-direction: column; height: calc(100vh - 104px); min-height: 560px; position: sticky; top: 88px;
    background: var(--ide-bg); color: var(--ide-text); border-radius: 18px; overflow: hidden; box-shadow: 0 12px 40px rgba(11, 18, 38, .25); }
.ide-toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--ide-bar); border-bottom: 1px solid var(--ide-line); flex-wrap: wrap; }
.ide-run { border: 0; border-radius: 9px; padding: 8px 16px; background: #22a55b; color: #fff; font: 800 15px var(--sc-text); cursor: pointer; display: inline-flex; gap: 8px; align-items: center; }
.ide-run:hover { background: #26b865; }
.ide-run:disabled { background: #2b3a5f; color: var(--ide-muted); cursor: progress; }
.ide-btn { border: 1px solid var(--ide-line); border-radius: 9px; padding: 7px 12px; background: #16213f; color: var(--ide-text); font: 700 14px var(--sc-text); cursor: pointer; }
.ide-btn:hover { background: #1e2b52; }
.ide-btn[aria-pressed="true"] { background: #3158dd; border-color: #3158dd; color: #fff; }
.ide-sep { width: 1px; height: 22px; background: var(--ide-line); margin: 0 4px; }
.ide-saved { margin-left: auto; font: 700 13px var(--sc-text); color: var(--ide-muted); }
.ide-saved.is-bad { color: #ff8f8f; }
.ide-main { flex: 1; display: flex; min-height: 0; }

/* Explorador */
.ide-explorer { width: 190px; flex: none; background: var(--ide-side); border-right: 1px solid var(--ide-line); display: flex; flex-direction: column; font: 600 14px var(--sc-text); }
.ide-explorer-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ide-muted); }
.ide-explorer-head button { border: 0; background: transparent; color: var(--ide-text); font-size: 18px; width: 26px; height: 26px; border-radius: 6px; cursor: pointer; }
.ide-explorer-head button:hover { background: #1e2b52; }
.ide-folder { padding: 4px 12px; font-weight: 800; font-size: 13px; color: var(--ide-text); }
.ide-files { list-style: none; margin: 0; padding: 0; overflow: auto; }
.ide-files li { display: flex; align-items: center; gap: 7px; padding: 5px 10px 5px 22px; cursor: pointer; color: var(--ide-text); }
.ide-files li:hover { background: #17223f; }
.ide-files li.is-active { background: #1f2d57; }
.ide-files li.has-error .ide-file-name { color: #ff8f8f; }
.ide-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--sc-mono); font-size: 13px; }
.ide-file-err { background: #c93c3c; color: #fff; font-size: 11px; border-radius: 9px; padding: 0 6px; }
.ide-file-act { display: none; gap: 2px; }
.ide-files li:hover .ide-file-act, .ide-files li.is-active .ide-file-act { display: flex; }
.ide-file-act button { border: 0; background: transparent; color: var(--ide-muted); cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 5px; }
.ide-file-act button:hover { background: #2a3a6a; color: #fff; }
.ide-explorer-tip { margin: auto 10px 10px; padding: 8px 10px; border-radius: 8px; background: #121c38; color: var(--ide-muted); font-size: 12px; line-height: 1.45; }
.ide-explorer-tip code { color: #8fb4ff; font: 600 11.5px var(--sc-mono); }

/* Pestañas y editor */
.ide-center { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ide-tabs { display: flex; background: var(--ide-bar); overflow-x: auto; min-height: 38px; scrollbar-width: thin; }
.ide-tab { display: flex; align-items: center; gap: 7px; padding: 0 8px 0 14px; height: 38px; border-right: 1px solid var(--ide-line); color: var(--ide-muted); font: 600 13px var(--sc-mono); cursor: pointer; white-space: nowrap; border-top: 2px solid transparent; }
.ide-tab.is-active { background: var(--ide-bg); color: #fff; border-top-color: #ffd65c; }
.ide-tab.has-error span:nth-child(2) { color: #ff8f8f; text-decoration: underline wavy #ff6b6b 1px; text-underline-offset: 3px; }
.ide-tab-main { font-style: normal; font-size: 9px; color: #22a55b; }
.ide-tab button { border: 0; background: transparent; color: inherit; width: 22px; height: 22px; border-radius: 5px; cursor: pointer; font-size: 16px; opacity: .5; }
.ide-tab:hover button, .ide-tab.is-active button { opacity: 1; }
.ide-tab button:hover { background: #2a3a6a; }
.ide-editor { flex: 1; min-height: 200px; position: relative; }
.ide-loading { margin: 24px; color: var(--ide-muted); font: 700 15px var(--sc-text); }
.ide-exec-line { background: rgba(255, 214, 92, .16); }
.ide-exec-glyph::before { content: "▶"; color: #ffd65c; font-size: 12px; margin-left: 4px; }

/* Terminal y problemas */
.ide-panel { height: 190px; flex: none; display: flex; flex-direction: column; border-top: 1px solid var(--ide-line); background: var(--ide-side); }
.ide-panel-tabs { display: flex; align-items: center; gap: 4px; padding: 0 10px; border-bottom: 1px solid var(--ide-line); }
.ide-panel-tabs [role="tab"] { border: 0; background: transparent; color: var(--ide-muted); font: 800 11.5px var(--sc-text); letter-spacing: .08em; text-transform: uppercase; padding: 9px 8px 7px; cursor: pointer; border-bottom: 2px solid transparent; }
.ide-panel-tabs [aria-selected="true"] { color: #fff; border-bottom-color: #ffd65c; }
.ide-panel-tabs b { background: #2a3a6a; border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.ide-panel-tabs b.is-bad { background: #c93c3c; color: #fff; }
.ide-panel-clear { margin-left: auto; border: 0; background: transparent; color: #8fb4ff; font: 700 12px var(--sc-text); cursor: pointer; }
.ide-terminal { flex: 1; margin: 0; padding: 8px 14px; overflow: auto; font: 500 13.5px/1.55 var(--sc-mono); color: #e8edfb; white-space: pre-wrap; word-break: break-word; font-variant-ligatures: none; }
.ide-terminal .is-prompt { color: #5fcf8a; }
.ide-terminal .is-cmd { color: #fff; font-weight: 700; }
.ide-terminal .is-info { color: var(--ide-muted); }
.ide-terminal .is-ok { color: #5fcf8a; font-weight: 700; }
.ide-terminal .is-error { color: #ff8f8f; }
.ide-terminal .is-error-src { color: #ffd2d2; }
.ide-problems { flex: 1; margin: 0; padding: 4px 0; list-style: none; overflow: auto; font: 600 13px var(--sc-text); }
.ide-problems[hidden], .ide-terminal[hidden] { display: none; }
.ide-problems li { display: flex; gap: 8px; align-items: baseline; padding: 4px 14px; cursor: pointer; }
.ide-problems li:hover { background: #17223f; }
.ide-problems li.is-error > span:first-child { color: #ff6b6b; }
.ide-problems li.is-warning > span:first-child { color: #ffc93c; }
.ide-problems li.is-ok { color: #5fcf8a; cursor: default; }
.ide-problems small { margin-left: auto; color: var(--ide-muted); white-space: nowrap; font-family: var(--sc-mono); }

/* Barra de estado */
.ide-status { display: flex; gap: 16px; align-items: center; padding: 3px 12px; background: #3158dd; color: #fff; font: 600 12px var(--sc-text); white-space: nowrap; overflow: hidden; }
.ide-status .is-bad { background: #c93c3c; padding: 0 6px; border-radius: 4px; }
.ide-status-right { margin-left: auto; }

/* ===================== Panel de simulación (columna derecha del modo Python) ===================== */
.sim-mission.is-ide { grid-template-columns: minmax(0, 1fr) minmax(420px, 1.05fr); }
.simv { --hud: rgba(10, 17, 36, .82); --hud-line: rgba(255, 255, 255, .09); --hud-text: #e8edfb; --hud-muted: #8d9ac2;
    position: sticky; top: 88px; height: calc(100vh - 104px); min-height: 560px; display: flex; flex-direction: column;
    background: #0b1226; color: var(--hud-text); border-radius: 18px; overflow: hidden; box-shadow: 0 12px 40px rgba(11, 18, 38, .25); }
.simv-bar { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 14px; background: #0b1226; border-bottom: 1px solid #1f2b4d; min-height: 50px; }
.simv-live { display: inline-flex; align-items: center; gap: 8px; font: 800 12px var(--sc-text); letter-spacing: .08em; text-transform: uppercase; flex: none; }
.simv-live i { width: 8px; height: 8px; border-radius: 50%; background: #4f5d86; }
.is-running .simv-live i { background: #2fd27a; animation: simv-pulse 1.4s infinite; }
@keyframes simv-pulse { 0% { box-shadow: 0 0 0 0 rgba(47, 210, 122, .6); } 70% { box-shadow: 0 0 0 8px rgba(47, 210, 122, 0); } 100% { box-shadow: 0 0 0 0 rgba(47, 210, 122, 0); } }
.simv-meta { color: var(--hud-muted); font: 700 13px var(--sc-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.simv-cams { margin-left: auto; display: inline-flex; background: #141e3b; border: 1px solid #1f2b4d; border-radius: 9px; padding: 2px; flex: none; }
.simv-cams button { border: 0; background: none; color: #aebbe3; font: 700 13px var(--sc-text); padding: 6px 11px; border-radius: 7px; cursor: pointer; }
.simv-cams button:hover { color: #fff; }
.simv-cams button[aria-pressed="true"] { background: #3158dd; color: #fff; }

/* El escenario ocupa todo el panel */
.simv .simv-stage.sim-stage-card { flex: 1; min-height: 0; padding: 0; border-radius: 0; position: relative;
    background: radial-gradient(ellipse at 50% 38%, #26375f 0%, #152043 48%, #0b1226 100%); }
.simv .simv-stage .sim-stage { position: absolute; inset: 0; min-height: 0; }

/* Paneles flotantes (HUD) */
.simv-hud { position: absolute; z-index: 3; background: var(--hud); border: 1px solid var(--hud-line); border-radius: 12px; color: var(--hud-text);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.simv-hud small { display: block; font: 800 11px var(--sc-text); letter-spacing: .08em; text-transform: uppercase; color: var(--hud-muted); }
.simv-tops { position: absolute; z-index: 3; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; pointer-events: none; }
.simv-tops > * { pointer-events: auto; position: relative; }
.simv-goal { max-width: 380px; min-width: 0; padding: 10px 13px; }
.simv-goal p { margin: 3px 0 0; font: 700 14px/1.4 var(--sc-text); }
.simv-goal .simv-hint { color: #ffd65c; font-weight: 600; border-top: 1px solid var(--hud-line); padding-top: 6px; margin-top: 7px; }
.simv-goal .simv-warn { color: #ffb4a0; font-weight: 600; border-top: 1px solid var(--hud-line); padding-top: 6px; margin-top: 7px; }
.simv-goal .simv-warn a { color: #8fb4ff; }
.simv-goal [hidden] { display: none; }

.simv-score { flex: none; width: min(250px, 42%); padding: 0; }
.simv-score summary { display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; list-style: none; }
.simv-score summary::-webkit-details-marker { display: none; }
.simv-score summary small { margin-right: auto; }
.simv-score summary b { font: 800 21px var(--sc-title); color: #fff; font-variant-numeric: tabular-nums; }
.simv-score summary span { font: 700 12px var(--sc-text); color: var(--hud-muted); white-space: nowrap; }
.simv-score ol { list-style: none; margin: 0; padding: 5px 6px 6px; border-top: 1px solid var(--hud-line); display: grid; gap: 2px; max-height: 40vh; overflow: auto; }
.simv-score li { display: flex; justify-content: space-between; gap: 10px; font: 600 12.5px/1.35 var(--sc-text); padding: 5px 7px; border-radius: 7px; color: #c9d3f0; }
.simv-score li b { font: 700 12.5px var(--sc-mono); white-space: nowrap; color: var(--hud-muted); }
.simv-score li small { display: inline; font: 600 11.5px var(--sc-text); letter-spacing: 0; text-transform: none; }
.simv-score li.is-full { background: rgba(47, 210, 122, .14); }
.simv-score li.is-full b { color: #5fe3a0; }
.simv-score li.is-part { background: rgba(255, 201, 60, .13); }
.simv-score li.is-part b { color: #ffd65c; }
.simv-score li.is-zero { background: rgba(255, 107, 107, .13); }
.simv-score li.is-zero b { color: #ff8f8f; }

.simv-timer { left: 12px; bottom: 12px; padding: 8px 12px 9px; width: 156px; }
.simv .simv-timer .sim-chip.is-timer { position: static; background: none; box-shadow: none; padding: 0; color: var(--hud-text); font: 700 16px var(--sc-title); font-variant-numeric: tabular-nums; }
.simv .simv-timer .sim-chip.is-timer.is-late { background: none; color: #ff8f8f; }
.simv-progress { display: block; height: 4px; margin-top: 6px; border-radius: 4px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.simv-progress b { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #3158dd, #5fa8ff); border-radius: 4px; transition: width .2s linear; }
.simv-progress.is-late b { background: linear-gradient(90deg, #ff9d7a, #ff6b6b); }

.simv-zoom { position: absolute; right: 12px; bottom: 12px; z-index: 3; display: flex; flex-direction: column; background: var(--hud); border: 1px solid var(--hud-line); border-radius: 10px; overflow: hidden; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.simv-zoom button { width: 38px; height: 36px; border: 0; background: none; color: var(--hud-text); font: 700 18px var(--sc-text); cursor: pointer; }
.simv-zoom button + button { border-top: 1px solid var(--hud-line); }
.simv-zoom button:hover { background: rgba(255, 255, 255, .08); }

.simv-status { position: absolute; z-index: 3; left: 180px; right: 62px; bottom: 12px; margin: 0;
    background: var(--hud); border: 1px solid var(--hud-line); border-radius: 10px; padding: 8px 13px; font: 700 13.5px/1.4 var(--sc-text); color: var(--hud-text);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); text-align: left; }
.simv-status:empty { display: none; }
.simv-status[data-kind="win"] { border-color: rgba(47, 210, 122, .5); color: #8ff0bd; }
.simv-status[data-kind="error"] { border-color: rgba(255, 107, 107, .5); color: #ffb4a8; }
.simv-status[data-kind="warn"] { border-color: rgba(255, 201, 60, .45); color: #ffe08a; }

.simv-foot { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid #1f2b4d; background: #0b1226; }
.simv-foot > span { font: 800 11px var(--sc-text); letter-spacing: .08em; text-transform: uppercase; color: var(--hud-muted); }
.simv-missions { display: flex; gap: 5px; flex-wrap: wrap; }
.simv-missions a, .simv-missions span { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; font: 700 13px var(--sc-mono); text-decoration: none;
    background: #141e3b; color: #aebbe3 !important; border: 1px solid #1f2b4d; position: relative; }
.simv-missions a:hover { border-color: #3158dd; color: #fff !important; }
.simv-missions .is-done { border-color: rgba(47, 210, 122, .55); color: #5fe3a0 !important; }
.simv-missions .is-done::after { content: ''; position: absolute; right: -3px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #2fd27a; border: 2px solid #0b1226; }
.simv-missions .is-now { background: #3158dd; border-color: #3158dd; color: #fff !important; }
.simv-missions .is-locked { opacity: .38; }
.is-ide .monaco-hover, .is-ide .suggest-widget .details { font-family: var(--sc-text); }

@media (max-width: 1100px) {
    .sim-mission.is-ide { grid-template-columns: 1fr; }
    .ide { position: relative; top: 0; height: 78vh; }
    .simv { position: relative; top: 0; height: 72vh; min-height: 480px; }
}
@media (max-width: 700px) {
    .ide-explorer { width: 136px; }
    .ide-explorer-tip { display: none; }
    .ide-status span:nth-child(n+4) { display: none; }
    .simv-meta { display: none; }
    .simv-tops { flex-direction: column; align-items: stretch; gap: 8px; }
    .simv-goal { max-width: none; }
    .simv-score { width: auto; }
    .simv-status { left: 12px; right: 62px; bottom: 74px; }
}

/* ===================== Editor de bloques (Junior) ===================== */
.bk { position: sticky; top: 88px; height: calc(100vh - 104px); min-height: 520px; display: flex; flex-direction: column; background: #fff;
    border: 1px solid #e3e8f4; border-radius: 18px; overflow: hidden; box-shadow: 0 12px 40px rgba(11, 18, 38, .1); }
.bk-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #fbfcff; border-bottom: 1px solid #e3e8f4; flex-wrap: wrap; }
.bk-run { border: 0; border-radius: 12px; padding: 10px 22px; background: #22a55b; color: #fff; font: 900 17px var(--sc-text); cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 3px 0 #178a47; transition: background .15s, transform .05s; }
.bk-run:hover { background: #26b865; }
.bk-run:active { transform: translateY(2px); box-shadow: 0 1px 0 #178a47; }
.bk-run:disabled { background: #c9d3e6; box-shadow: 0 3px 0 #b3bfd6; cursor: not-allowed; }
.is-running .bk-run { background: #f6c42b; color: #2b3550; box-shadow: 0 3px 0 #d9a514; }
.bk-btn { border: 1px solid #dbe2f0; border-radius: 11px; padding: 9px 14px; background: #fff; color: var(--sc-navy); font: 800 15px var(--sc-text); cursor: pointer; }
.bk-btn:hover { background: #f2f5fc; }
.bk-btn[aria-pressed="true"] { background: #3158dd; border-color: #3158dd; color: #fff; }
.bk-btn.is-ghost { border-color: transparent; background: none; color: var(--sc-muted); }
.bk-btn.is-ghost:hover { color: #d92d20; background: #fdf1f0; }
.bk-sep { width: 1px; height: 26px; background: #e3e8f4; margin: 0 2px; }
.bk-hint { flex: 1; min-width: 0; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--sc-muted); font: 700 13px var(--sc-text); }
.bk-toolbar { flex-wrap: nowrap; }
.bk .sim-blockly { flex: 1; height: auto; min-height: 0; border: 0; border-radius: 0; }
@media (max-width: 1100px) { .bk { position: relative; top: 0; height: 72vh; min-height: 460px; } }
@media (max-width: 700px) {
    .bk-hint, .bk-sep { display: none; }
    .bk-toolbar { gap: 6px; padding: 8px; flex-wrap: wrap; }
    .bk-run { flex: 1; justify-content: center; padding: 9px 12px; font-size: 16px; }
    .bk-btn { padding: 8px 10px; font-size: 14px; white-space: nowrap; }
}
