/* ============================================================
   PyPractica — estilos
   ============================================================ */
:root {
  --bg: #0d1220;
  --bg-2: #121a2b;
  --panel: #16203a;
  --panel-2: #1b2745;
  --border: #26314f;
  --border-2: #33406a;
  --text: #e8edf7;
  --text-dim: #9aa7c7;
  --text-faint: #6b7899;
  --accent: #6c9cff;
  --accent-2: #8f7bff;
  --yellow: #ffd43b;
  --blue: #4b8bbe;
  --green: #34d399;
  --red: #f87171;
  --orange: #fbbf24;
  --radius: 12px;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

* { box-sizing: border-box; }

/* Regla crítica: el atributo hidden SIEMPRE oculta,
   aunque otra regla le ponga display (evita overlays fantasma) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
}

button { font-family: inherit; cursor: pointer; }
code { font-family: var(--mono); }

/* ============ Pantalla de carga / error ============ */
#boot, #fatal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 20% -10%, #1c2a4e 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #241c4e 0%, transparent 55%),
    var(--bg);
  z-index: 1000;
}
.boot-card {
  text-align: center;
  max-width: 480px;
  padding: 40px 36px;
}
.boot-logo { font-size: 64px; line-height: 1; }
.boot-card h1 { margin: 10px 0 4px; font-size: 34px; letter-spacing: -0.5px; }
.boot-sub { color: var(--text-dim); margin: 0 0 22px; }
.boot-spinner {
  width: 42px; height: 42px;
  margin: 0 auto 16px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: girar 0.9s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }
.boot-stage { color: var(--accent); font-weight: 600; min-height: 22px; }
.boot-facts { margin-top: 18px; min-height: 44px; }
.boot-facts p {
  color: var(--text-dim);
  font-size: 13.5px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 0;
  animation: aparecer 0.5s ease;
}
.boot-note { margin-top: 14px; color: var(--text-faint); font-size: 12.5px; }
.fatal-help {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 18px;
}
.fatal-help pre {
  background: #0a0f1c;
  padding: 10px 12px;
  border-radius: 8px;
  font-family: var(--mono);
  color: var(--green);
  overflow: auto;
}
.diag-box {
  text-align: left;
  background: #0a0f1c;
  border: 1px solid rgba(248,113,113,0.4);
  color: #fca5a5;
  padding: 12px 14px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow: auto;
  margin: 14px 0 0;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15px;
}
.btn-primary:hover { filter: brightness(1.1); }
@keyframes aparecer { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* ============ Estructura general ============ */
#app { height: 100%; display: flex; flex-direction: column; }

#topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.icon-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: 18px;
  padding: 4px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 30px; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -0.3px; }
.brand-sub { font-size: 11.5px; color: var(--text-faint); margin-top: -2px; }
.tb-flex, .flex { flex: 1; }

.top-stats { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.level-chip {
  background: linear-gradient(135deg, #2b3a68, #3a2b68);
  border: 1px solid var(--border-2);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
}
.xp-wrap { display: flex; align-items: center; gap: 8px; }
.xp-bar {
  width: 140px; height: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
#xp-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--yellow), var(--orange));
  transition: width 0.6s ease;
}
.xp-label { font-size: 12.5px; color: var(--yellow); font-weight: 700; white-space: nowrap; }
.progress-pill {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--green);
  font-weight: 700;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

#layout { flex: 1; display: flex; min-height: 0; }

/* ============ Sidebar ============ */
#sidebar {
  width: 285px;
  flex: 0 0 auto;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#nav { flex: 1; overflow-y: auto; padding: 12px 10px 20px; }

.mod-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  padding: 9px 10px;
  border-radius: 10px;
  text-align: left;
  font-weight: 700;
  font-size: 14px;
}
.mod-head:hover { background: var(--panel); }
.mod-head .mod-icon { font-size: 17px; }
.mod-head .mod-count {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-faint);
  font-weight: 600;
  background: var(--panel);
  padding: 2px 8px;
  border-radius: 999px;
}
.mod-items { margin: 2px 0 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 6px 10px 6px 34px;
  border-radius: 8px;
  font-size: 13.5px;
  text-align: left;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(108,156,255,0.18), rgba(143,123,255,0.10));
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}
.ex-state {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
}
.ex-state.pending { background: var(--panel-2); color: var(--text-faint); border: 1px solid var(--border); }
.ex-state.attempted { background: rgba(251,191,36,0.14); color: var(--orange); border: 1px solid rgba(251,191,36,0.55); }
.ex-state.solved { background: rgba(52,211,153,0.15); color: var(--green); border: 1px solid rgba(52,211,153,0.5); }
.ex-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-xp { font-size: 10.5px; color: var(--text-faint); flex: 0 0 auto; }

#sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.5;
}

/* ============ Zona principal ============ */
#main { flex: 1; display: flex; min-width: 0; min-height: 0; }

#left-pane {
  flex: 0 0 380px;
  max-width: 42%;
  border-right: 1px solid var(--border);
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
#statement-scroll { overflow-y: auto; padding: 22px 24px 40px; flex: 1; }

#right-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
}

/* ============ Toolbar del editor ============ */
#toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  flex-wrap: wrap;
}
#toolbar button {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  transition: filter 0.15s;
}
#toolbar button:hover { filter: brightness(1.25); }
#toolbar button:disabled { opacity: 0.45; cursor: not-allowed; }
.tb-run { background: linear-gradient(135deg, #2e7d54, #2c9c66) !important; border-color: #2e9c66 !important; }
.tb-check { background: linear-gradient(135deg, var(--accent), var(--accent-2)) !important; border-color: var(--accent) !important; }
.kbd {
  font-size: 10px;
  color: rgba(255,255,255,0.75);
  background: rgba(0,0,0,0.25);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  font-family: var(--mono);
}
.tb-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
#save-state { font-size: 11.5px; color: var(--green); opacity: 0; transition: opacity 0.3s; }
#save-state.show { opacity: 1; }
#py-state {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}
#py-state.ok { color: var(--green); border-color: rgba(52,211,153,0.5); }
#py-state.busy { color: var(--yellow); border-color: rgba(255,212,59,0.5); }

/* ============ Editor ============ */
#editor { flex: 1; min-height: 140px; }

/* ============ Panel inferior ============ */
#bottom {
  flex: 0 0 200px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #0e1526;
}
#bottom-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.btab {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
}
.btab.active { background: var(--panel-2); color: var(--text); }
.btab:hover { color: var(--text); }
.mini {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 7px;
}
.mini:hover { color: var(--text); filter: brightness(1.15); }
.mini.danger:hover { color: var(--red); border-color: rgba(248,113,113,0.5); }

#console-view { flex: 1; overflow: auto; min-height: 0; }
#console {
  margin: 0;
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-dim);
}
#console .c-out { color: var(--text); }
#console .c-err { color: var(--red); }
#console .c-sys { color: var(--text-faint); font-style: italic; }
#console .c-ok { color: var(--green); }

#files-view { flex: 1; overflow: auto; min-height: 0; padding: 10px 14px; }
#files-actions { display: flex; gap: 8px; margin-bottom: 10px; }
#files-list { list-style: none; margin: 0; padding: 0; }
#files-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13.5px;
}
#files-list li:hover { background: var(--panel); }
.file-name { flex: 1; font-family: var(--mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--text-faint); font-size: 11.5px; }
.file-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 6px;
}
.file-btn:hover { color: var(--text); background: var(--panel-2); }
.file-btn.del:hover { color: var(--red); }
#files-note { margin-top: 12px; color: var(--text-faint); font-size: 12px; line-height: 1.5; }
#files-note code { color: var(--text-dim); }

/* ============ Enunciado / Teoría ============ */
#statement { line-height: 1.65; font-size: 14.5px; }
#statement h2 { font-size: 22px; margin: 4px 0 14px; letter-spacing: -0.4px; }
#statement h3 {
  font-size: 17px;
  margin: 26px 0 10px;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
#statement h4 { font-size: 15px; margin: 18px 0 8px; color: var(--text); }
#statement p { margin: 8px 0; color: var(--text-dim); }
#statement p strong, #statement li strong { color: var(--text); }
#statement ul, #statement ol { color: var(--text-dim); padding-left: 22px; margin: 8px 0; }
#statement li { margin: 4px 0; }
#statement .ic {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--yellow);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 12.5px;
  font-family: var(--mono);
  white-space: nowrap;
}

.crumb {
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  margin-bottom: 8px;
}
.ex-meta { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; flex-wrap: wrap; }
.chip {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--panel);
}
.chip.gold { color: var(--yellow); border-color: rgba(255,212,59,0.4); }
.chip.green { color: var(--green); border-color: rgba(52,211,153,0.45); background: rgba(52,211,153,0.08); }
.chip.blue { color: var(--accent); border-color: rgba(108,156,255,0.45); }
.badge-solved {
  font-size: 12px;
  font-weight: 800;
  color: var(--green);
  background: rgba(52,211,153,0.12);
  border: 1px solid rgba(52,211,153,0.5);
  padding: 3px 10px;
  border-radius: 999px;
}

/* bloques de código en el enunciado */
.codebox {
  background: #0a0f1c;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 10px 0;
  overflow: hidden;
}
.codebox pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.8px;
  line-height: 1.6;
  color: #d7e3ff;
}
.codebox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--mono);
}
.try-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
}
.try-btn:hover { filter: brightness(1.15); }
.codebox.out pre { color: var(--green); }
.codebox.out::before {
  content: "Salida";
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  padding: 6px 14px 0;
  font-family: var(--sans);
}

/* callouts */
.callout {
  border-radius: 10px;
  padding: 11px 14px;
  margin: 12px 0;
  font-size: 13.5px;
  line-height: 1.6;
  border: 1px solid;
}
.callout.tip    { background: rgba(108,156,255,0.08);  border-color: rgba(108,156,255,0.35); }
.callout.warn   { background: rgba(248,113,113,0.08);  border-color: rgba(248,113,113,0.35); }
.callout.idea   { background: rgba(255,212,59,0.07);   border-color: rgba(255,212,59,0.3); }

/* quiz */
.quiz {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 14px 0;
}
.quiz-q { font-weight: 700; margin-bottom: 10px; font-size: 14px; }
.quiz-opts { display: flex; flex-direction: column; gap: 7px; }
.quiz-opt {
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  transition: border-color 0.15s;
}
.quiz-opt:hover { border-color: var(--accent); color: var(--text); }
.quiz-opt.correct {
  border-color: var(--green);
  background: rgba(52,211,153,0.12);
  color: var(--text);
}
.quiz-opt.wrong {
  border-color: var(--red);
  background: rgba(248,113,113,0.1);
  animation: sacudir 0.35s ease;
}
@keyframes sacudir {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.quiz-fb {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.5;
  display: none;
  border-radius: 8px;
  padding: 9px 12px;
}
.quiz-fb.good { display: block; background: rgba(52,211,153,0.1); color: var(--green); }
.quiz-fb.bad  { display: block; background: rgba(248,113,113,0.1); color: var(--red); }

/* tablas */
#statement table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}
#statement th {
  text-align: left;
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 12px;
  border: 1px solid var(--border);
  font-size: 12.5px;
}
#statement td {
  padding: 7px 12px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
#statement td code { color: var(--yellow); font-size: 12px; }

/* pistas */
.hint-box {
  background: rgba(255,212,59,0.06);
  border: 1px solid rgba(255,212,59,0.3);
  border-radius: 10px;
  padding: 11px 14px;
  margin: 12px 0;
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.6;
  animation: aparecer 0.3s ease;
}
.hint-box strong { color: var(--yellow); }

/* resultados de las pruebas */
#results { margin-top: 4px; }
.result-card {
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 16px;
  border: 1px solid;
  animation: aparecer 0.3s ease;
}
.result-card.err { background: rgba(248,113,113,0.07); border-color: rgba(248,113,113,0.4); }
.result-card.err pre {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--red);
  margin: 6px 0 0;
}
.result-card.win { background: rgba(52,211,153,0.07); border-color: rgba(52,211,153,0.45); }
.result-title { font-weight: 800; font-size: 15px; }
.result-card.err .result-title { color: var(--red); }
.result-card.win .result-title { color: var(--green); }
.result-sub { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.test-row {
  display: flex;
  gap: 9px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
  align-items: flex-start;
}
.test-row:last-child { border-bottom: none; }
.test-ico { flex: 0 0 auto; font-weight: 800; }
.test-row.pass .test-ico { color: var(--green); }
.test-row.fail .test-ico { color: var(--red); }
.test-body { flex: 1; min-width: 0; }
.test-desc { color: var(--text-dim); }
.test-row.fail .test-desc { color: var(--text); }
.test-detail {
  margin-top: 3px;
  color: var(--red);
  font-family: var(--mono);
  font-size: 11.8px;
  background: rgba(248,113,113,0.08);
  border-radius: 6px;
  padding: 5px 8px;
  word-break: break-word;
}
.results-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ============ Modal ============ */
#modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 16, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}
#modal-card {
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  width: min(680px, 100%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
#modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
}
#modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
}
#modal-close:hover { color: var(--text); background: var(--panel-2); }
#modal-body { padding: 16px 18px; overflow-y: auto; font-size: 14px; line-height: 1.6; color: var(--text-dim); }
#modal-body pre {
  background: #0a0f1c;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  color: #d7e3ff;
}
#modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

/* ============ Toasts ============ */
#toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 600;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: aparecer 0.25s ease;
  max-width: 320px;
}
.toast.gold { border-color: rgba(255,212,59,0.5); color: var(--yellow); }
.toast.green { border-color: rgba(52,211,153,0.5); color: var(--green); }
.toast.red { border-color: rgba(248,113,113,0.5); color: var(--red); }

/* ============ Confetti ============ */
.confetti {
  position: fixed;
  top: 90px;
  width: 10px;
  height: 10px;
  z-index: 700;
  pointer-events: none;
  animation: confetti-caer 1.5s ease-in forwards;
}
@keyframes confetti-caer {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--dx), 78vh) rotate(var(--rot)); opacity: 0; }
}

/* ============ Scrollbars ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #43517e; }

/* ============ Responsive ============ */
@media (max-width: 1150px) {
  #left-pane { flex: 0 0 330px; }
}
@media (max-width: 950px) {
  #main { flex-direction: column; }
  #left-pane {
    flex: 0 0 42%;
    max-width: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .icon-btn { display: inline-block; }
  #sidebar {
    position: fixed;
    top: 57px;
    left: 0; bottom: 0;
    z-index: 400;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 8px 0 30px rgba(0,0,0,0.5);
    width: 290px;
  }
  #sidebar.open { transform: translateX(0); }
  .xp-bar { width: 80px; }
}
@media (max-width: 620px) {
  .brand-sub, .kbd { display: none; }
  .level-chip { display: none; }
  #left-pane { flex: 0 0 45%; }
  #bottom { flex: 0 0 160px; }
  .user-chip .user-name { display: none; }
}

/* ============ Pantalla de Login / Registro ============ */
#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  background:
    radial-gradient(1200px 600px at 20% -10%, #1c2a4e 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 110%, #241c4e 0%, transparent 55%),
    var(--bg);
}
.auth-card {
  width: min(440px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 16px;
  padding: 26px 26px 24px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55);
  animation: aparecer 0.35s ease;
}
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-logo { font-size: 46px; line-height: 1; }
.auth-head h1 { margin: 8px 0 4px; font-size: 26px; letter-spacing: -0.4px; }
.auth-sub { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.5; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 16px;
}
.auth-tab {
  background: none;
  border: none;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 13.5px;
  padding: 8px 10px;
  border-radius: 7px;
  transition: background 0.15s, color 0.15s;
}
.auth-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.auth-error {
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.45);
  color: #fecaca;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-label { font-size: 12px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-field span { font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.auth-field input {
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 9px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.auth-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(108,156,255,0.2); }

.auth-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
}
.auth-submit { width: 100%; margin-top: 4px; padding: 11px 16px; }

.recent-users { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.recent-user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--text);
}
.recent-user-btn:hover { border-color: var(--accent); background: var(--panel-2); }
.recent-user-btn .ru-ava { font-size: 20px; }
.recent-user-btn .ru-info { flex: 1; min-width: 0; }
.recent-user-btn .ru-name { font-weight: 700; font-size: 13.5px; display: block; }
.recent-user-btn .ru-meta { font-size: 11.5px; color: var(--text-faint); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.ava-opt {
  width: 38px; height: 38px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ava-opt.active {
  border-color: var(--accent);
  background: rgba(108,156,255,0.2);
  box-shadow: 0 0 0 2px rgba(108,156,255,0.25);
}

.auth-credit {
  position: fixed;
  right: 20px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: 340px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(22, 32, 58, 0.78);
  border: 1px solid rgba(108, 156, 255, 0.28);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  animation: aparecer 0.45s ease;
}
.auth-credit-badge {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: linear-gradient(135deg, rgba(108,156,255,0.22), rgba(143,123,255,0.22));
  border: 1px solid rgba(108,156,255,0.35);
}
.auth-credit-kicker {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--accent);
}
.auth-credit-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
}
.auth-credit-role {
  font-size: 11.2px;
  color: var(--text-dim);
  line-height: 1.35;
  margin-top: 1px;
}
@media (max-width: 820px) {
  #auth-screen {
    flex-direction: column;
    justify-content: flex-start;
    gap: 14px;
    padding-top: 24px;
    padding-bottom: 24px;
  }
  .auth-credit {
    position: static;
    max-width: min(440px, 100%);
    width: 100%;
  }
}

/* ============ Chip de usuario y resumen ============ */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--panel);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.user-chip:hover { border-color: var(--accent); background: var(--panel-2); }

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}
.logout-btn:hover {
  color: var(--red);
  border-color: rgba(248,113,113,0.55);
  background: rgba(248,113,113,0.08);
}

#sidebar-resume {
  padding: 10px 10px 4px;
  border-bottom: 1px solid var(--border);
}
.sidebar-resume-btn {
  width: 100%;
  text-align: left;
  background: linear-gradient(135deg, rgba(108,156,255,0.12), rgba(143,123,255,0.1));
  border: 1px solid rgba(108,156,255,0.35);
  border-radius: 10px;
  padding: 9px 11px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sidebar-resume-btn:hover { border-color: var(--accent); filter: brightness(1.08); }
.sidebar-resume-btn .sr-top { font-size: 11px; font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: 0.4px; }
.sidebar-resume-btn .sr-loc { font-size: 12.5px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-resume-btn .sr-sub { font-size: 11px; color: var(--text-dim); }

.resume-banner {
  background: linear-gradient(135deg, rgba(108,156,255,0.13), rgba(52,211,153,0.08));
  border: 1px solid rgba(108,156,255,0.4);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  animation: aparecer 0.3s ease;
}
.resume-banner-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.resume-banner-title { font-weight: 800; font-size: 13.5px; color: var(--text); }
.resume-banner-close { background: none; border: none; color: var(--text-faint); font-size: 14px; padding: 2px 6px; }
.resume-banner-close:hover { color: var(--text); }
.resume-banner-text { font-size: 13px; color: var(--text-dim); margin: 5px 0 0; line-height: 1.5; }
.resume-banner-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ============ Retroalimentación enriquecida ============ */
.result-card.warn { background: rgba(251,191,36,0.07); border-color: rgba(251,191,36,0.45); }
.result-card.warn .result-title { color: var(--orange); }
.result-card.info { background: rgba(108,156,255,0.08); border-color: rgba(108,156,255,0.45); }
.result-card.info .result-title { color: var(--accent); }

.feedback-box {
  margin-top: 10px;
  background: rgba(10, 15, 28, 0.55);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.feedback-label {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 6px;
}
.feedback-list {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
}
.feedback-list li { margin: 3px 0; }
.feedback-list.pos li { color: #a7f3d0; }

/* ============ Modal de perfil / progreso ============ */
.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
.profile-avatar { font-size: 40px; line-height: 1; }
.profile-name { font-size: 17px; font-weight: 800; color: var(--text); }
.profile-meta { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }
.mod-prog-list { display: flex; flex-direction: column; gap: 9px; margin: 12px 0 16px; }
.mod-prog-row { display: flex; flex-direction: column; gap: 4px; }
.mod-prog-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--text); font-weight: 600; }
.mod-prog-bar { height: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.mod-prog-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
