/* ═══════════════════════════════════════════════════════════════════════════
   Codelearn · Sistema de diseño
   ÚNICO lugar donde se definen los colores, sombras y tipografía.
   No declares variables :root en ningún otro archivo ni sección.
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  color-scheme: light;

  /* Marca (decorativo: fondos, barras, favicon) */
  --brand: #76B31E;
  --brand-dark: #184A12;
  --brand-lime: #C8D200;
  --brand-rgb: 118 179 30;

  /* Primario (texto, botones, enlaces) — todos ≥ 4,5:1 sobre blanco */
  --primary-900: #0F2E0B;
  --primary-700: #12390E;
  --primary: #184A12;
  --brand-text: #4A7312;
  --accent: #4A7312;
  --primary-300: #A9C77E;
  --primary-200: #D3E2C2;
  --primary-100: #E5F0D0;
  --primary-50: #F3F8E9;
  --primary-rgb: 24 74 18;

  /* Degradado oscuro de marca (paneles con texto blanco) */
  --grad-brand: linear-gradient(125deg, var(--primary-900) 0%, var(--primary) 55%, var(--brand-text) 100%);

  /* Superficies y bordes */
  --bg: #F7F9F4;
  --surface: #FFFFFF;
  --surface-2: #F8FAF6;
  --surface-3: #F0F4EA;
  --border: #E1E8D9;
  --border-strong: #C9D5BE;

  /* Texto */
  --text: #20291B;
  --text-2: #3F4A38;
  --muted: #71806A;

  /* Estados (semánticos, no de marca) */
  --success: #16a34a;
  --success-50: #f0fdf4;
  --success-100: #dcfce7;
  --warning: #b45309;
  --warning-50: #fffbeb;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --info: #1e40af;
  --info-50: #eff6ff;
  --flame: #f97316;

  /* Colores auxiliares del logotipo */
  --brand-green: #76B31E;
  --brand-purple: #C37CC6;
  --brand-teal: #82C0C7;
  --brand-red: #CD5C5C;
  --brand-orange: #EDB059;

  /* Formas y sombras */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgb(var(--primary-rgb) / .05);
  --shadow: 0 5px 20px rgb(var(--primary-rgb) / .07);
  --shadow-md: 0 8px 26px rgb(var(--primary-rgb) / .09);
  --shadow-lg: 0 18px 48px rgb(var(--primary-rgb) / .13);

  /* Tipografía y medidas */
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', Consolas, 'Courier New', monospace;
  --sidebar: 252px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 0.4em; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 750; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0 0 0.8em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-3); border: 1px solid var(--border); padding: 0.1em 0.35em; border-radius: 6px; }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--brand-text); outline-offset: 2px; }
.i { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ─── Botones ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 600; font-size: 0.92rem;
  cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none !important;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgb(var(--primary-rgb) / .3); }
.btn-primary:hover:not(:disabled) { background: var(--primary-700); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-soft { background: var(--primary-50); color: var(--primary-700); }
.btn-soft:hover:not(:disabled) { background: var(--primary-100); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 0.84rem; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 0; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ─── Formularios ─────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 0.8rem; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 12px; font: inherit; font-size: 0.93rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { min-height: 90px; resize: vertical; }
.textarea.mono, .input.mono { font-family: var(--mono); font-size: 0.85rem; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgb(var(--primary-rgb) / .15); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.form-error { background: var(--danger-50); color: var(--danger); border: 1px solid #fecaca; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 0.88rem; margin-bottom: 14px; }
.form-ok { background: var(--success-50); color: #166534; border: 1px solid #bbf7d0; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 0.88rem; margin-bottom: 14px; }

/* ─── Estructura principal ────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; transition: transform 0.25s var(--ease);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--text); text-decoration: none !important; }
.brand-text strong { display: block; font-size: 1.02rem; letter-spacing: -0.01em; }
.brand-text span { display: block; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; color: var(--primary); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--text-2); font-weight: 550; font-size: 0.93rem; text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--primary-50); color: var(--primary-700); }
.nav a.active .i { color: var(--primary); }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.sidebar-foot a { font-size: 0.85rem; display: flex; align-items: center; gap: 8px; color: var(--muted); padding: 6px 12px; }
.main { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 64px; display: flex; align-items: center; gap: 12px;
  padding: 0 28px; background: rgba(244, 247, 251, 0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar .menu-btn { display: none; }
.topbar-title { font-weight: 650; font-size: 0.95rem; color: var(--text-2); }
.topbar-stats { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.stat-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 650; font-size: 0.88rem; color: var(--text-2);
}
.stat-pill .i { width: 16px; height: 16px; }
.stat-pill.flame .i { color: var(--flame); }
.stat-pill.flame.off .i { color: var(--border-strong); }
.stat-pill.xp .i { color: var(--primary); }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.user-btn span.name { font-weight: 600; font-size: 0.88rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 50;
}
.dropdown.open .dropdown-menu { display: block; animation: pop 0.15s var(--ease); }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px; color: var(--text-2); background: none; border: 0; cursor: pointer; font-size: 0.9rem; text-align: left; text-decoration: none; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); }
.dropdown-head { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dropdown-head small { display: block; color: var(--muted); }
.content { padding: 24px 28px 48px; max-width: 1320px; width: 100%; margin: 0 auto; flex: 1; }
.content.full { max-width: none; padding: 0; }
.footer { padding: 22px 28px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.82rem; display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; background: var(--surface); }
.footer a { color: var(--muted); }
.scrim { display: none; }

@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view { animation: fadeUp 0.3s var(--ease); }

/* ─── Tarjetas y rejillas ─────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head a { font-size: 0.85rem; font-weight: 600; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 650; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.chip .i { width: 13px; height: 13px; }
.chip-blue { background: var(--primary-50); color: var(--primary-700); }
.chip-green { background: var(--success-100); color: #166534; }
.chip-amber { background: #fef3c7; color: #92400e; }
.chip-red { background: #fee2e2; color: #991b1b; }
.chip-violet { background: #ede9fe; color: #5b21b6; }

.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 0.6s var(--ease); }
.progress.thin { height: 5px; }
.progress.green span { background: var(--success); }
.ring { position: relative; display: inline-grid; place-items: center; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--surface-3); }
.ring-fg { stroke: var(--primary); stroke-linecap: round; transition: stroke-dashoffset 0.8s var(--ease); }
.ring span { font-weight: 750; font-size: 0.9rem; }

.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 700; flex: none; letter-spacing: 0.02em; }

.tabs { display: inline-flex; gap: 4px; background: var(--surface-3); padding: 4px; border-radius: 12px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 0.86rem; color: var(--muted); cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .i { width: 40px; height: 40px; color: var(--border-strong); margin-bottom: 10px; }
.empty h3 { color: var(--text-2); }
.loading { display: grid; place-items: center; padding: 60px; }
.spin { width: 28px; height: 28px; border: 3px solid var(--primary-100); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Panel principal ─────────────────────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden; border-radius: 18px; padding: 26px 28px; color: #fff;
  background: var(--grad-brand);
  display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.hero::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.18;
  background-image: radial-gradient(circle at 1px 1px, #fff 1px, transparent 0); background-size: 22px 22px;
  mask-image: linear-gradient(90deg, transparent 30%, #000);
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { color: #fff; margin-bottom: 4px; }
.hero p { color: rgba(255, 255, 255, 0.85); margin: 0; }
.hero-user { display: flex; align-items: center; gap: 16px; }
.hero-user .avatar { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25); }
.hero-level { min-width: 260px; background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 14px; padding: 14px 16px; }
.hero-level .row-between { font-size: 0.85rem; margin-bottom: 8px; }
.hero-level .progress { background: rgba(255, 255, 255, 0.22); }
.hero-level .progress span { background: #fff; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; gap: 14px; align-items: center; }
.kpi-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); flex: none; }
.kpi-icon.orange { background: #fff7ed; color: var(--flame); }
.kpi-icon.green { background: var(--success-50); color: var(--success); }
.kpi-icon.violet { background: #f5f3ff; color: #7c3aed; }
.kpi strong { display: block; font-size: 1.35rem; line-height: 1.1; font-weight: 750; }
.kpi span { font-size: 0.8rem; color: var(--muted); }
.continue {
  display: flex; align-items: center; gap: 18px; padding: 18px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.continue .course-thumb { width: 64px; height: 64px; border-radius: 14px; }
.continue-body { flex: 1; min-width: 0; }
.continue-body .eyebrow { font-size: 0.75rem; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.08em; }
.continue-body h3 { margin: 2px 0 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow strong { display: block; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .grow span { font-size: 0.8rem; color: var(--muted); }
.rank-num { width: 26px; text-align: center; font-weight: 750; color: var(--muted); font-size: 0.9rem; }
.rank-num.top1 { color: #d97706; }
.rank-num.top2 { color: #64748b; }
.rank-num.top3 { color: #b45309; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 12px; }
.badge-item { text-align: center; padding: 12px 6px; border-radius: 12px; }
.badge-item .badge-icon { width: 54px; height: 54px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #fbbf24, #f97316); color: #fff; box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3); }
.badge-item .badge-icon .i { width: 26px; height: 26px; }
.badge-item.locked .badge-icon { background: var(--surface-3); color: var(--border-strong); box-shadow: none; }
.badge-item strong { display: block; font-size: 0.8rem; line-height: 1.25; }
.badge-item span { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 2px; }
.mission { padding: 12px 0; border-bottom: 1px solid var(--border); }
.mission:last-child { border-bottom: 0; }
.mission .row-between { margin-bottom: 6px; }
.mission strong { font-size: 0.9rem; }
.mission small { color: var(--muted); }

/* ─── Cursos ──────────────────────────────────────────────────────────────── */
.course-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; transition: transform 0.2s var(--ease), box-shadow 0.2s; color: inherit; text-decoration: none !important;
}
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.course-cover { position: relative; height: 132px; display: grid; place-items: center; color: #fff; overflow: hidden; }
.course-cover::before {
  content: ''; position: absolute; inset: 0; opacity: 0.22;
  background-image: linear-gradient(rgba(255, 255, 255, 0.6) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.6) 1px, transparent 1px);
  background-size: 24px 24px; mask-image: radial-gradient(circle at 70% 30%, #000, transparent 75%);
}
.course-cover .i { width: 52px; height: 52px; position: relative; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.2)); }
.course-cover .cover-tag { position: absolute; top: 12px; left: 12px; }
.course-cover .cover-status { position: absolute; top: 12px; right: 12px; }
.cover-tag .chip, .cover-status .chip { background: rgba(255, 255, 255, 0.92); }
.course-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.course-body h3 { margin: 0; }
.course-body p { color: var(--muted); font-size: 0.88rem; margin: 0; }
.course-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.8rem; color: var(--muted); margin-top: auto; }
.course-meta span { display: inline-flex; align-items: center; gap: 5px; }
.course-meta .i { width: 14px; height: 14px; }
.course-thumb { display: grid; place-items: center; color: #fff; flex: none; }
.course-thumb .i { width: 28px; height: 28px; }
.course-header { border-radius: 18px; padding: 28px; color: #fff; position: relative; overflow: hidden; display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.course-header h1 { color: #fff; }
.course-header p { color: rgba(255, 255, 255, 0.88); max-width: 640px; }
.course-header .course-thumb { width: 88px; height: 88px; border-radius: 20px; background: rgba(255, 255, 255, 0.16); }
.course-header .course-thumb .i { width: 44px; height: 44px; }
.course-header .chip { background: rgba(255, 255, 255, 0.18); color: #fff; }
.unit { padding: 0; overflow: hidden; }
.unit-head { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.unit-num { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 750; background: var(--primary-50); color: var(--primary-700); flex: none; }
.unit.done .unit-num { background: var(--success-100); color: #166534; }
.unit.locked .unit-num { background: var(--surface-3); color: var(--muted); }
.unit-head .grow { flex: 1; min-width: 0; }
.unit-head p { margin: 0; font-size: 0.85rem; color: var(--muted); }
.lesson-row { display: flex; align-items: center; gap: 14px; padding: 13px 20px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none !important; }
.lesson-row:last-child { border-bottom: 0; }
a.lesson-row:hover { background: var(--surface-2); }
.lesson-row.locked { color: var(--muted); cursor: not-allowed; }
.lesson-state { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 2px solid var(--border-strong); color: var(--muted); }
.lesson-row.done .lesson-state { background: var(--success); border-color: var(--success); color: #fff; }
.lesson-row.current .lesson-state { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.lesson-state .i { width: 15px; height: 15px; }
.lesson-row .grow { flex: 1; min-width: 0; }
.lesson-row .grow strong { display: block; font-size: 0.93rem; }
.lesson-row .grow span { font-size: 0.8rem; color: var(--muted); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-btn { border: 1px solid var(--border); background: var(--surface); padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 0.85rem; color: var(--text-2); cursor: pointer; }
.filter-btn:hover { border-color: var(--border-strong); }
.filter-btn.active { background: var(--text); color: #fff; border-color: var(--text); }

/* ─── Página de aprendizaje (3 paneles) ───────────────────────────────────── */
.learn { display: grid; grid-template-columns: 280px minmax(0, 1fr) minmax(0, 1.1fr); height: calc(100vh - 64px); }
.learn-index { border-right: 1px solid var(--border); background: var(--surface); overflow-y: auto; padding: 16px 0; }
.learn-index .back { display: flex; align-items: center; gap: 6px; padding: 0 18px 12px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.learn-index h3 { padding: 0 18px; font-size: 0.98rem; }
.learn-index .progress { margin: 8px 18px 16px; }
.idx-unit { padding: 10px 18px 4px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.idx-lesson { display: flex; align-items: flex-start; gap: 10px; padding: 8px 18px; font-size: 0.88rem; color: var(--text-2); text-decoration: none !important; border-left: 3px solid transparent; }
.idx-lesson:hover { background: var(--surface-2); }
.idx-lesson.active { background: var(--primary-50); border-left-color: var(--primary); color: var(--primary-700); font-weight: 600; }
.idx-lesson.locked { color: var(--border-strong); pointer-events: none; }
.idx-lesson .i { width: 16px; height: 16px; margin-top: 2px; }
.idx-lesson.done .i { color: var(--success); }
.idx-acts { display: flex; gap: 4px; padding: 0 18px 6px 44px; }
.idx-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.idx-dot.done { background: var(--success); }
.idx-dot.current { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.learn-content { overflow-y: auto; padding: 28px 32px 40px; background: var(--bg); }
.learn-content .crumbs { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.steps { display: flex; gap: 6px; margin: 16px 0 22px; flex-wrap: wrap; }
.step-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 0.82rem; font-weight: 600; color: var(--text-2); cursor: pointer; }
.step-btn.active { border-color: var(--primary); background: var(--primary-50); color: var(--primary-700); }
.step-btn.done { border-color: #86efac; background: var(--success-50); color: #166534; }
.step-btn .i { width: 14px; height: 14px; }
.prose { font-size: 0.98rem; color: var(--text-2); }
.prose p, .prose li { line-height: 1.7; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 0.9em; }
.prose strong { color: var(--text); }
.block { margin-bottom: 16px; }
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; font-size: 0.93rem; }
.callout .i { margin-top: 2px; }
.callout p:last-child { margin: 0; }
.callout-tip { background: var(--primary-50); border: 1px solid var(--primary-100); color: var(--primary-700); }
.callout-warning { background: var(--warning-50); border: 1px solid #fde68a; color: #78350f; }
.code-view { background: #0f172a; color: #e2e8f0; border-radius: 12px; overflow: hidden; font-family: var(--mono); font-size: 0.85rem; }
.code-view header { display: flex; justify-content: space-between; align-items: center; padding: 7px 14px; background: #1e293b; color: #94a3b8; font-size: 0.75rem; font-family: var(--font); font-weight: 600; }
.code-view pre { margin: 0; padding: 14px 16px; overflow-x: auto; line-height: 1.6; }
.task { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.task-type { font-size: 0.74rem; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.08em; display: flex; align-items: center; gap: 8px; }
.task h2 { margin: 6px 0 10px; }
.hints { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.hint-item { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; background: #fffbeb; border: 1px solid #fde68a; font-size: 0.9rem; color: #78350f; animation: fadeUp 0.25s var(--ease); }
.hint-item .i { color: #d97706; margin-top: 2px; }
.learn-work { border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.work-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.work-head strong { font-size: 0.9rem; }
.work-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.work-foot { border-top: 1px solid var(--border); padding: 12px 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--surface); }
.work-foot .spacer { flex: 1; }
.lesson-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; }
.mobile-switch { display: none; }

/* Resultado de corrección */
.feedback { border-radius: 12px; padding: 14px 16px; display: flex; gap: 12px; animation: fadeUp 0.25s var(--ease); }
.feedback .i { width: 22px; height: 22px; margin-top: 1px; }
.feedback strong { display: block; margin-bottom: 2px; }
.feedback p { margin: 4px 0 0; font-size: 0.9rem; }
.feedback-ok { background: var(--success-50); border: 1px solid #bbf7d0; color: #14532d; }
.feedback-ok .i { color: var(--success); }
.feedback-bad { background: var(--danger-50); border: 1px solid #fecaca; color: #7f1d1d; }
.feedback-bad .i { color: var(--danger); }
.feedback-info { background: var(--primary-50); border: 1px solid var(--primary-100); color: var(--primary-700); }
.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ─── Actividades interactivas ────────────────────────────────────────────── */
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); cursor: pointer; text-align: left; font-size: 0.95rem; color: var(--text); transition: border-color 0.15s, background 0.15s;
}
.option:hover { border-color: var(--border-strong); }
.option.selected { border-color: var(--primary); background: var(--primary-50); }
.option.right { border-color: var(--success); background: var(--success-50); }
.option.wrong { border-color: var(--danger); background: var(--danger-50); }
.option .key { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); font-weight: 700; font-size: 0.8rem; color: var(--muted); flex: none; }
.option.selected .key { background: var(--primary); color: #fff; }
.fill-code { background: #0f172a; color: #e2e8f0; border-radius: 12px; padding: 18px; font-family: var(--mono); font-size: 0.9rem; line-height: 2.1; white-space: pre-wrap; overflow-x: auto; }
.fill-code input {
  font-family: var(--mono); font-size: 0.88rem; background: #1e293b; color: #fff; border: 2px solid var(--brand); border-radius: 6px;
  padding: 1px 6px; min-width: 60px; width: 8ch; outline: none;
}
.fill-code input:focus { border-color: var(--brand-lime); box-shadow: 0 0 0 3px rgb(var(--brand-rgb) / .3); }
.fill-code input.right { border-color: #22c55e; }
.fill-code input.wrong { border-color: #ef4444; }
.order-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.order-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 2px solid var(--border);
  background: var(--surface); cursor: grab; user-select: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.order-item.mono span.txt { font-family: var(--mono); font-size: 0.86rem; white-space: pre; }
.order-item.dragging { opacity: 0.5; }
.order-item.over { border-color: var(--primary); }
.order-item.right { border-color: var(--success); background: var(--success-50); }
.order-item.wrong { border-color: var(--danger); background: var(--danger-50); }
.order-item .num { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-3); font-weight: 700; font-size: 0.78rem; color: var(--muted); flex: none; }
.order-item .txt { flex: 1; }
.order-item .moves { display: flex; gap: 2px; }
.order-item .moves button { width: 28px; height: 28px; border: 0; background: var(--surface-3); border-radius: 7px; cursor: pointer; color: var(--text-2); display: grid; place-items: center; }
.order-item .moves button:hover { background: var(--primary-100); color: var(--primary-700); }
.order-item .moves .i { width: 14px; height: 14px; }
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-item {
  padding: 11px 14px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface); cursor: pointer; text-align: left;
  font-size: 0.9rem; color: var(--text); display: flex; align-items: center; gap: 8px; min-height: 48px; transition: border-color 0.15s, background 0.15s;
}
.match-item:hover { border-color: var(--border-strong); }
.match-item.active { border-color: var(--primary); background: var(--primary-50); }
.match-item.paired { border-style: solid; }
.match-item .tag { margin-left: auto; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 0.72rem; font-weight: 800; color: #fff; flex: none; }
.match-item.right { border-color: var(--success); background: var(--success-50); }
.match-item.wrong { border-color: var(--danger); background: var(--danger-50); }
.output-answer { font-family: var(--mono); min-height: 90px; }

/* ─── Editor de código ────────────────────────────────────────────────────── */
.editor-wrap { border: 1px solid #1e293b; border-radius: 12px; overflow: hidden; background: #0f172a; display: flex; flex-direction: column; min-height: 260px; }
.editor-tabs { display: flex; background: #1e293b; padding: 0 6px; gap: 2px; align-items: center; }
.editor-tabs button { border: 0; background: transparent; color: #94a3b8; padding: 9px 14px; font-size: 0.8rem; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 6px; }
.editor-tabs button.active { color: #fff; border-bottom-color: var(--accent); }
.editor-tabs .lang { margin-left: auto; color: #64748b; font-size: 0.75rem; padding: 0 10px; }
.code-editor { position: relative; display: flex; flex: 1; min-height: 240px; font-family: var(--mono); font-size: 0.875rem; line-height: 1.6; }
.code-editor .gutter { padding: 12px 10px 12px 8px; text-align: right; color: #475569; user-select: none; min-width: 44px; background: #0f172a; border-right: 1px solid #1e293b; white-space: pre; overflow: hidden; }
.code-editor .gutter .err { color: #f87171; font-weight: 700; }
.code-editor .scroller { position: relative; flex: 1; overflow: auto; }
.code-editor pre, .code-editor textarea {
  margin: 0; padding: 12px 14px; border: 0; font: inherit; line-height: inherit; white-space: pre; tab-size: 2;
  min-height: 100%; width: 100%; letter-spacing: 0; word-spacing: 0;
}
.code-editor pre { position: absolute; inset: 0; pointer-events: none; color: #e2e8f0; overflow: visible; }
.code-editor textarea { position: relative; display: block; resize: none; background: transparent; color: transparent; caret-color: #f8fafc; outline: none; overflow: hidden; }
.code-editor textarea::selection { background: rgb(var(--brand-rgb) / .4); color: transparent; }
.code-editor.readonly textarea { caret-color: transparent; }
.tok-kw { color: #c084fc; }
.tok-str { color: #86efac; }
.tok-num { color: #fbbf24; }
.tok-com { color: #64748b; font-style: italic; }
.tok-fn { color: #60a5fa; }
.tok-tag { color: #f472b6; }
.tok-attr { color: #fbbf24; }
.tok-prop { color: #67e8f9; }
.tok-op { color: #94a3b8; }
.console { background: #0b1220; border: 1px solid #1e293b; border-radius: 12px; font-family: var(--mono); font-size: 0.82rem; color: #cbd5e1; overflow: hidden; }
.console header { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px; background: #111a2e; color: #94a3b8; font-family: var(--font); font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.console-body { padding: 10px 12px; max-height: 200px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; min-height: 44px; }
.console-line.error { color: #fca5a5; }
.console-line.warn { color: #fcd34d; }
.console-line.info { color: #93c5fd; }
.console-empty { color: #475569; font-style: italic; }
.preview-frame { width: 100%; height: 220px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.preview-label { font-size: 0.76rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.tests { display: flex; flex-direction: column; gap: 6px; }
.test-row { display: flex; align-items: flex-start; gap: 10px; font-size: 0.88rem; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.test-row .i { width: 17px; height: 17px; margin-top: 2px; color: var(--muted); }
.test-row.pass { background: var(--success-50); border-color: #bbf7d0; }
.test-row.pass .i { color: var(--success); }
.test-row.fail { background: var(--danger-50); border-color: #fecaca; }
.test-row.fail .i { color: var(--danger); }
.test-row small { display: block; color: var(--muted); font-family: var(--mono); font-size: 0.78rem; }

/* ─── Retos y ranking ─────────────────────────────────────────────────────── */
.challenge-feature { position: relative; overflow: hidden; border-radius: var(--radius); padding: 20px; color: #fff; display: flex; flex-direction: column; gap: 10px; min-height: 190px; }
.challenge-feature.daily { background: var(--grad-brand); }
.challenge-feature.weekly { background: linear-gradient(135deg, #4338ca, #7c3aed); }
.challenge-feature h3 { color: #fff; margin: 0; font-size: 1.15rem; }
.challenge-feature p { color: rgba(255, 255, 255, 0.85); margin: 0; font-size: 0.9rem; }
.challenge-feature .chip { background: rgba(255, 255, 255, 0.18); color: #fff; }
.challenge-feature .btn { margin-top: auto; align-self: flex-start; background: #fff; color: var(--text); }
.challenge-card { display: flex; flex-direction: column; gap: 10px; }
.challenge-card .row-between { align-items: flex-start; }
.podium { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; align-items: end; margin-bottom: 18px; }
.podium-item { text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 12px; }
.podium-item.p1 { padding-top: 26px; border-color: #fcd34d; box-shadow: 0 8px 24px rgba(245, 158, 11, 0.15); }
.podium-item .place { font-weight: 800; font-size: 0.8rem; color: var(--muted); margin-bottom: 8px; }
.podium-item.p1 .place { color: #d97706; }
.podium-item strong { display: block; margin-top: 8px; }
.podium-item span { font-size: 0.85rem; color: var(--muted); }
tr.me td { background: var(--primary-50) !important; }

/* ─── Gráficos ────────────────────────────────────────────────────────────── */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#chart-area); }
.chart .bar { fill: var(--primary); }
.chart .bar.dim { fill: var(--primary-100); }
.chart .hover-line { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }
.chart-tip { position: absolute; pointer-events: none; background: var(--text); color: #fff; font-size: 0.78rem; padding: 6px 10px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity 0.12s; z-index: 5; }
.chart-tip.show { opacity: 1; }
.chart-tip strong { display: block; }
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat-cell { width: 14px; height: 14px; border-radius: 3px; background: var(--surface-3); }
.heat-cell.l1 { background: var(--primary-100); }
.heat-cell.l2 { background: var(--primary-300); }
.heat-cell.l3 { background: var(--brand); }
.heat-cell.l4 { background: var(--primary); }
.heat-legend { display: flex; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--muted); margin-top: 8px; }
.heat-legend .heat-cell { width: 11px; height: 11px; }
.bars-h { display: flex; flex-direction: column; gap: 12px; }
.bar-h .row-between { font-size: 0.86rem; margin-bottom: 5px; }

/* ─── Autenticación ───────────────────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-side {
  position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: var(--grad-brand);
}
.auth-side::before {
  content: ''; position: absolute; inset: 0; opacity: 0.16;
  background-image: linear-gradient(rgba(255, 255, 255, 0.5) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.5) 1px, transparent 1px);
  background-size: 32px 32px; mask-image: radial-gradient(circle at 30% 60%, #000, transparent 70%);
}
.auth-side > * { position: relative; }
.auth-side h1 { color: #fff; font-size: 2.3rem; max-width: 460px; }
.auth-side p { color: rgba(255, 255, 255, 0.85); max-width: 440px; font-size: 1.02rem; }
.auth-features { display: grid; gap: 14px; margin-top: 28px; }
.auth-feature { display: flex; gap: 14px; align-items: center; }
.auth-feature .kpi-icon { background: rgba(255, 255, 255, 0.14); color: #fff; }
.auth-code { font-family: var(--mono); font-size: 0.85rem; background: rgba(2, 6, 23, 0.45); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 14px; padding: 16px 18px; max-width: 420px; line-height: 1.7; }
.auth-main { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.auth-box { width: 100%; max-width: 400px; }
.auth-box h2 { font-size: 1.6rem; }
.auth-box .sub { color: var(--muted); margin-bottom: 24px; }
.auth-alt { text-align: center; margin-top: 18px; font-size: 0.9rem; color: var(--muted); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.8rem; margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ─── Toasts, modales, logros ─────────────────────────────────────────────── */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--text); color: #fff; box-shadow: var(--shadow-lg); font-size: 0.9rem; max-width: 380px; transform: translateY(10px); opacity: 0; transition: all 0.25s var(--ease); }
.toast.show { transform: none; opacity: 1; }
.toast-success .i { color: #4ade80; }
.toast-error .i { color: #f87171; }
.toast-info .i { color: #60a5fa; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 90; display: grid; place-items: center; padding: 20px; opacity: 0; transition: opacity 0.2s; }
.modal-backdrop.show { opacity: 1; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 520px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); transform: translateY(10px) scale(0.98); transition: transform 0.2s var(--ease); }
.modal-backdrop.show .modal { transform: none; }
.modal-wide { max-width: 980px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.achievement { position: fixed; top: 80px; left: 50%; z-index: 110; display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 20px 14px 14px; box-shadow: var(--shadow-lg); transform: translate(-50%, -20px); opacity: 0; transition: all 0.35s var(--ease); min-width: 280px; }
.achievement.show { transform: translate(-50%, 0); opacity: 1; }
.achievement-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #fbbf24, #f97316); color: #fff; flex: none; }
.achievement-icon .i { width: 24px; height: 24px; }
.achievement strong { display: block; }
.achievement span { font-size: 0.88rem; color: var(--muted); }
.xp-float { position: fixed; top: 70px; right: 140px; z-index: 120; font-weight: 800; color: var(--primary); font-size: 1.2rem; pointer-events: none; animation: xpUp 1.6s var(--ease) forwards; }
@keyframes xpUp { 0% { opacity: 0; transform: translateY(20px) scale(0.8); } 20% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-30px); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 105; }

/* ─── Administración ──────────────────────────────────────────────────────── */
.admin-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
.tree { display: flex; flex-direction: column; gap: 4px; }
.tree-unit { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.tree-unit > header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface-2); font-weight: 650; font-size: 0.9rem; }
.tree-unit > header .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-lesson { padding: 8px 12px 8px 14px; border-top: 1px solid var(--border); }
.tree-lesson > .row-between { font-size: 0.88rem; font-weight: 600; }
.tree-acts { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.tree-act { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; font-size: 0.83rem; color: var(--text-2); cursor: pointer; }
.tree-act:hover { background: var(--surface-3); }
.tree-act.active { background: var(--primary-50); color: var(--primary-700); }
.tree-act .i { width: 14px; height: 14px; }
.mini-btns { display: flex; gap: 2px; }
.mini-btns button { width: 26px; height: 26px; border: 0; background: transparent; border-radius: 7px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.mini-btns button:hover { background: var(--surface-3); color: var(--text); }
.mini-btns .i { width: 14px; height: 14px; }
.block-editor { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--surface-2); }
.block-editor .row-between { margin-bottom: 8px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; cursor: pointer; transition: background 0.2s; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::before { transform: translateX(18px); }
.section-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.section-tabs a { padding: 10px 14px; font-weight: 600; font-size: 0.9rem; color: var(--muted); border-bottom: 2px solid transparent; text-decoration: none; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.section-tabs a.active { color: var(--primary-700); border-bottom-color: var(--primary); }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .learn { grid-template-columns: 240px minmax(0, 1fr) minmax(0, 1fr); }
  .dash-grid { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 1100px) {
  .learn { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .learn-index { display: none; }
  .learn.show-index .learn-index { display: block; position: fixed; z-index: 35; top: 64px; bottom: 0; left: var(--sidebar); width: 290px; box-shadow: var(--shadow-lg); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); z-index: 39; }
  .main { margin-left: 0; }
  .topbar { padding: 0 14px; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar-title { display: none; }
  .user-btn span.name { display: none; }
  .content { padding: 18px 14px 40px; }
  .learn { display: block; height: auto; }
  .learn.show-index .learn-index { left: 0; }
  .learn-content { padding: 20px 16px; }
  .learn-work { border-left: 0; border-top: 1px solid var(--border); }
  .learn[data-pane='work'] .learn-content, .learn[data-pane='content'] .learn-work { display: none; }
  .mobile-switch { display: flex; position: sticky; top: 64px; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 14px; gap: 8px; }
  .mobile-switch button { flex: 1; }
  .work-body { overflow: visible; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .hero { padding: 20px; }
  .hero-level { min-width: 0; width: 100%; }
  .match-grid { gap: 8px; }
  .podium { gap: 8px; }
  .stat-pill.lvl { display: none; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px; gap: 10px; }
  .kpi-icon { width: 36px; height: 36px; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .stat-pill { padding: 0 9px; }
  h1 { font-size: 1.45rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
.option p, .match-item p, .hint-item p { margin: 0; }
.option > span:last-child { flex: 1; }
.search-box { position: relative; }
.search-box .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box .input { padding-left: 38px; }
.code-view pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; border-radius: 0; }
@media (min-width: 1101px) { .learn-content [data-toggle-index] { display: none; } }
@media (max-width: 560px) {
  .continue { flex-wrap: wrap; }
  .continue .btn { width: 100%; }
  .continue-body { min-width: 0; flex-basis: calc(100% - 82px); }
}

/* ==========================================================
   CODELEARN GTAHUB — FASE 2.1
   Renovación visual del dashboard y navegación
   ========================================================== */

/* Navegación */
.sidebar {
  padding: 22px 15px;
  background: #fff;
  border-right-color: #e8edf5;
}

.brand {
  padding: 5px 10px 24px;
}

.brand-text strong {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -.045em;
}

.brand-text span {
  font-size: .67rem;
  letter-spacing: .19em;
}

.nav {
  gap: 5px;
}

.nav-label {
  padding: 19px 12px 7px;
  font-size: .66rem;
  letter-spacing: .13em;
}

.nav a {
  min-height: 43px;
  border-radius: 11px;
  font-size: .89rem;
  font-weight: 600;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}

.nav a:hover {
  transform: translateX(2px);
}

.nav a.active {
  background: var(--primary-50);
  color: var(--primary);
  box-shadow: inset 3px 0 var(--brand);
}

.sidebar-foot {
  padding-top: 16px;
}

/* Barra superior */
.topbar {
  height: 68px;
  padding: 0 32px;
  background: rgba(248, 250, 253, .91);
  border-bottom-color: #e9edf4;
  backdrop-filter: blur(16px);
}

.topbar-title {
  font-weight: 700;
  letter-spacing: -.02em;
}

.user-btn {
  padding: 5px 11px 5px 5px;
  border-color: #e6ebf3;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}

.user-btn:hover {
  border-color: var(--primary-200);
  box-shadow: var(--shadow);
}

/* Área de contenido */
.content {
  max-width: 1440px;
  padding: 30px 34px 52px;
}

.stack {
  gap: 22px;
}

/* Tarjetas */
.card {
  padding: 23px;
  border-color: #e9edf4;
  border-radius: 17px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, border-color .2s ease;
}

.card:hover {
  border-color: #dce4f2;
  box-shadow: var(--shadow);
}

.card-head {
  margin-bottom: 19px;
}

.card-head h2,
.card-head h3 {
  letter-spacing: -.025em;
}

.card-head a {
  font-weight: 650;
}

/* Bienvenida */
.hero {
  padding: 32px;
  border-radius: 21px;
  background:
    radial-gradient(ellipse at 90% 10%, rgba(255,255,255,.16), transparent 38%),
    var(--grad-brand);
  box-shadow: 0 12px 30px rgb(var(--primary-rgb) / .17);
}

.hero h1 {
  font-size: clamp(1.55rem, 3vw, 2rem);
  font-weight: 800;
  letter-spacing: -.045em;
}

.hero p {
  color: rgba(255,255,255,.84);
}

.hero-user {
  gap: 17px;
}

.hero-level {
  max-width: 540px;
  padding: 16px 18px;
  margin-top: 24px;
  border: 1px solid rgba(255,255,255,.19);
  border-radius: 14px;
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(8px);
}

.hero-level .progress {
  background: rgba(255,255,255,.2);
}

.hero-level .progress span {
  background: linear-gradient(90deg, #fff, var(--brand-lime));
}

/* Estadísticas */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
}

.kpi {
  min-width: 0;
  padding: 19px;
  border: 1px solid #e9edf4;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease;
}

.kpi:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.kpi strong {
  display: block;
  font-size: 1.55rem;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -.045em;
}

.kpi span:not(.kpi-icon) {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 550;
}

.kpi-icon {
  border-radius: 12px;
}

/* Continuar aprendiendo */
.continue {
  padding: 21px;
  border: 1px solid var(--primary-100);
  border-radius: 17px;
  background: linear-gradient(110deg, var(--primary-50), #fff 80%);
  gap: 18px;
}

.continue-body h3 {
  font-size: 1.08rem;
  font-weight: 750;
}

.continue .btn {
  border-radius: 11px;
}

.eyebrow {
  color: var(--primary);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

/* Listas de cursos y clasificación */
.list-item {
  padding: 13px 10px;
  border-radius: 12px;
  transition: background .18s ease;
}

.list-item:hover {
  background: #f5f7fc;
}

.list-item strong {
  font-weight: 700;
}

.list-item span {
  line-height: 1.45;
}

.course-thumb {
  flex: none;
  display: inline-grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 4px 12px rgb(var(--primary-rgb) / .12);
}

.progress {
  background: #edf0f6;
}

.progress span {
  background: linear-gradient(90deg, var(--primary), var(--brand));
}

/* Misiones */
.mission {
  padding: 13px 0;
  border-bottom: 1px solid #edf0f5;
}

.mission:last-child {
  border-bottom: 0;
}

.mission strong {
  font-size: .9rem;
}

.mission small {
  color: var(--muted);
}

/* Retos */
.challenge-feature {
  padding: 17px;
  border-radius: 15px;
  border: 1px solid #e8edf5;
  background: #fafbfe;
  transition: transform .2s ease, box-shadow .2s ease;
}

.challenge-feature:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.challenge-feature h3 {
  margin-top: 13px;
  font-weight: 750;
}

.challenge-feature p {
  color: var(--muted);
  font-size: .86rem;
}

/* Insignias */
.badge-item {
  padding: 12px 7px;
  border-radius: 12px;
  background: #fafbfe;
  border: 1px solid #edf0f5;
}

.badge-icon {
  margin-bottom: 7px;
}

/* Botones */
.btn {
  border-radius: 11px;
  font-weight: 650;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.btn-primary {
  background: var(--primary);
  box-shadow: 0 3px 9px rgb(var(--primary-rgb) / .19);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-700);
  box-shadow: 0 5px 14px rgb(var(--primary-rgb) / .24);
  transform: translateY(-1px);
}

/* Pie */
.footer {
  border-top-color: #e9edf4;
}

/* Responsive */
@media (max-width: 1100px) {
  .content {
    padding: 25px 22px 42px;
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .topbar {
    padding: 0 16px;
  }

  .content {
    padding: 20px 16px 38px;
  }

  .hero {
    padding: 24px;
  }

  .card {
    padding: 19px;
  }

  .stack {
    gap: 17px;
  }
}

@media (max-width: 520px) {
  .content {
    padding: 16px 12px 32px;
  }

  .hero {
    padding: 20px;
    border-radius: 16px;
  }

  .hero-user {
    align-items: flex-start;
  }

  .hero h1 {
    font-size: 1.45rem;
  }

  .kpis {
    gap: 9px;
  }

  .kpi {
    padding: 13px 11px;
    border-radius: 13px;
  }

  .kpi strong {
    font-size: 1.3rem;
  }

  .card {
    padding: 16px;
  }

  .continue {
    padding: 15px;
  }

  .topbar-stats {
    gap: 5px;
  }
}

/* ==========================================================
   CODELEARN GTAHUB — FASE 2.2
   Catálogo de cursos
   ========================================================== */

.page-head {
  align-items: center;
  gap: 20px;
  margin-bottom: 25px;
}

.page-head h1 {
  font-size: clamp(1.65rem, 3vw, 2.1rem);
  font-weight: 850;
  letter-spacing: -.05em;
  color: var(--text);
}

.page-head p {
  max-width: 650px;
  margin-top: 7px;
  color: #64748b;
  line-height: 1.65;
}

.page-head .search-box {
  min-width: 260px !important;
}

.page-head .input {
  min-height: 44px;
  border-radius: 12px;
  border-color: #e0e6f0;
  background: #fff;
  box-shadow: 0 2px 8px rgb(var(--primary-rgb) / .035);
}

.page-head .input:focus {
  border-color: var(--brand-text);
  box-shadow: 0 0 0 3px rgb(var(--primary-rgb) / .1);
}

/* Filtros */
.filters {
  gap: 9px;
  margin-bottom: 24px;
  padding-bottom: 4px;
}

.filter-btn {
  padding: 9px 16px;
  border-radius: 10px;
  border-color: #e4e9f2;
  background: #fff;
  color: #52617a;
  font-size: .84rem;
  font-weight: 700;
  transition: all .2s ease;
}

.filter-btn:hover {
  border-color: var(--primary-300);
  color: var(--primary);
  background: var(--primary-50);
}

.filter-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 11px rgb(var(--primary-rgb) / .2);
}

/* Rejilla */
.grid-cards {
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 22px;
  align-items: stretch;
}

/* Tarjeta */
.course-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #e6ebf3;
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 3px 12px rgb(var(--primary-rgb) / .045);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}

.course-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary-200);
  box-shadow: 0 14px 30px rgb(var(--primary-rgb) / .11);
}

/* Portada */
.course-cover {
  height: 158px;
  isolation: isolate;
  position: relative;
}

.course-cover::before {
  opacity: .35;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.32), transparent 35%),
    radial-gradient(circle at 85% 85%, rgba(255,255,255,.22), transparent 38%);
}

.course-cover::after {
  content: '';
  position: absolute;
  z-index: -1;
  width: 180px;
  height: 180px;
  right: -65px;
  bottom: -105px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 50%;
  box-shadow: 0 0 0 22px rgba(255,255,255,.055),
              0 0 0 45px rgba(255,255,255,.04);
}

.course-cover > .i {
  width: 58px;
  height: 58px;
  filter: drop-shadow(0 8px 15px rgba(0,0,0,.2));
  transition: transform .25s ease;
}

.course-card:hover .course-cover > .i {
  transform: scale(1.1) rotate(-4deg);
}

.course-cover .chip {
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.2);
  color: #fff;
  backdrop-filter: blur(8px);
  font-weight: 750;
}

.course-cover .cover-tag,
.course-cover .cover-status {
  z-index: 2;
}

/* Contenido */
.course-body {
  min-height: 218px;
  padding: 19px;
  gap: 12px;
}

.course-body h3 {
  color: #1d2b45;
  font-size: 1.04rem;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: -.025em;
}

.course-body p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  min-height: 3.9em;
  color: #68768b;
  font-size: .85rem;
  line-height: 1.55;
}

.course-meta {
  padding-top: 12px;
  border-top: 1px solid #edf0f5;
  gap: 8px 13px;
  color: #718096;
  font-size: .76rem;
}

.course-meta span {
  gap: 5px;
}

.course-meta .i {
  color: var(--muted);
}

/* Progreso */
.course-body .progress {
  height: 7px;
  border-radius: 99px;
  background: #edf1f7;
}

.course-body .progress span {
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--brand));
}

.course-body .progress.green span {
  background: linear-gradient(90deg, #159b70, #35c48c);
}

/* Detalle de curso */
.course-header {
  padding: 32px;
  border-radius: 20px;
  box-shadow: 0 10px 28px rgb(var(--primary-rgb) / .1);
}

.course-header h1 {
  font-size: clamp(1.6rem, 3vw, 2.15rem);
  font-weight: 850;
  letter-spacing: -.045em;
}

.course-header p {
  line-height: 1.65;
}

.course-header .course-thumb {
  box-shadow: 0 8px 20px rgba(0,0,0,.12);
}

.unit {
  border-radius: 16px;
}

.lesson-row {
  border-radius: 11px;
  transition: background .18s ease, border-color .18s ease;
}

.lesson-row.current {
  background: var(--primary-50);
  border-color: var(--primary-100);
}

/* Móviles */
@media (max-width: 700px) {
  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .page-head .search-box {
    width: 100%;
    min-width: 0 !important;
  }

  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 0 10px;
    scrollbar-width: thin;
  }

  .filter-btn {
    flex: none;
  }

  .grid-cards {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .course-cover {
    height: 145px;
  }

  .course-body {
    min-height: 0;
  }

  .course-header {
    padding: 21px;
    gap: 16px;
  }

  .course-header > div:last-child {
    margin-left: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .course-card,
  .course-cover > .i,
  .filter-btn {
    transition: none;
  }
}

/* =========================================================
   CODELEARN GTAHUB — FASE 2.3
   Entorno profesional de programación
   ========================================================= */

/* Distribución general del aula */
.learn {
  background: var(--surface);
}

.learn-index {
  background: #fff;
}

.learn-content {
  padding: 30px 34px 44px;
}

.learn-content h1 {
  letter-spacing: -0.035em;
  line-height: 1.2;
  margin-top: 8px;
}

.learn-content .crumbs {
  font-weight: 600;
  letter-spacing: .01em;
}

.learn-content .steps {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

/* Enunciado e instrucciones */
.task {
  padding: 22px 24px;
  border-radius: 15px;
  box-shadow: 0 3px 12px rgba(15, 23, 42, .035);
}

.task-type {
  letter-spacing: .09em;
  font-size: .72rem;
}

.task h2 {
  font-size: 1.3rem;
  line-height: 1.35;
  letter-spacing: -.025em;
}

.task p {
  color: var(--text-2);
  line-height: 1.75;
}

.hints {
  margin-top: 18px;
}

.hint-item {
  border-radius: 11px;
  padding: 12px 14px;
  line-height: 1.55;
}

/* Panel de programación */
.learn-work {
  background: #f8fafc;
  border-left: 1px solid #dfe5ee;
}

.work-head {
  min-height: 54px;
  padding: 12px 18px;
  background: #fff;
  border-bottom: 1px solid #e5eaf1;
}

.work-head strong {
  font-size: .88rem;
  letter-spacing: -.01em;
}

.work-body {
  padding: 20px;
  gap: 16px;
  scrollbar-gutter: stable;
}

.work-foot {
  min-height: 62px;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #e5eaf1;
  box-shadow: 0 -4px 14px rgba(15, 23, 42, .025);
}

/* Editor: apariencia de IDE */
.editor-wrap {
  min-height: 350px;
  border: 1px solid #263449;
  border-radius: 13px;
  background: #0b1220;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
}

.editor-tabs {
  min-height: 43px;
  padding: 0 9px;
  background: #172235;
  border-bottom: 1px solid #29374d;
}

.editor-tabs button {
  min-height: 43px;
  padding: 0 16px;
  font-size: .78rem;
  transition: background .15s, color .15s;
}

.editor-tabs button:hover {
  background: rgba(255,255,255,.055);
  color: #fff;
}

.editor-tabs button.active {
  background: #0b1220;
  color: #fff;
  border-bottom: 2px solid var(--brand);
}

.editor-tabs .lang {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.code-editor {
  min-height: 300px;
  font-size: .86rem;
  line-height: 1.7;
  background: #0b1220;
}

.code-editor .gutter {
  min-width: 52px;
  padding: 15px 12px 15px 8px;
  background: #0b1220;
  border-right: 1px solid #1e293b;
  color: #64748b;
  line-height: 1.7;
}

.code-editor pre,
.code-editor textarea {
  padding: 15px 18px;
  line-height: 1.7;
  tab-size: 2;
}

.code-editor textarea {
  caret-color: var(--brand-lime);
}

.code-editor textarea:focus {
  outline: none;
}

.code-editor .scroller {
  scrollbar-color: #475569 #0b1220;
  scrollbar-width: thin;
}

/* Consola de ejecución */
.console {
  border: 1px solid #263449;
  border-radius: 12px;
  background: #0b1220;
  box-shadow: 0 4px 14px rgba(15, 23, 42, .07);
}

.console header {
  min-height: 39px;
  padding: 8px 13px;
  background: #172235;
  border-bottom: 1px solid #29374d;
  color: #cbd5e1;
  font-size: .72rem;
  letter-spacing: .08em;
}

.console header button {
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 4px 9px;
  background: #1e293b;
  color: #cbd5e1;
  font-size: .72rem;
  cursor: pointer;
}

.console header button:hover {
  background: #334155;
  color: #fff;
}

.console-body {
  min-height: 58px;
  max-height: 230px;
  padding: 13px 15px;
  font-size: .79rem;
  line-height: 1.7;
  scrollbar-color: #475569 #0b1220;
  scrollbar-width: thin;
}

.console-line {
  padding: 1px 0;
  color: #d1d5db;
}

.console-line.error {
  color: #fca5a5;
}

.console-line.warn {
  color: #fcd34d;
}

.console-line.info {
  color: #93c5fd;
}

.console-empty {
  color: #64748b;
}

/* Vista previa y pruebas */
.preview-label {
  margin-bottom: 9px;
  font-size: .72rem;
  letter-spacing: .09em;
}

.preview-frame {
  min-height: 220px;
  border: 1px solid #dbe3ed;
  border-radius: 12px;
  box-shadow: 0 3px 12px rgba(15, 23, 42, .04);
}

.tests {
  gap: 8px;
}

.test-row {
  padding: 10px 12px;
  border-radius: 10px;
  line-height: 1.5;
}

/* Botones del entorno */
.work-foot .btn {
  min-height: 38px;
  border-radius: 9px;
  font-weight: 650;
}

.work-foot .btn-primary {
  box-shadow: 0 3px 8px rgb(var(--primary-rgb) / .17);
}

.work-foot .btn:disabled {
  opacity: .55;
  cursor: wait;
}

/* Repaso de teoría dentro de una actividad */
.learn-content details.card {
  border-radius: 13px;
  border-color: var(--border);
  background: #fff;
}

.learn-content details summary {
  color: var(--text-2);
  font-size: .9rem;
}

.learn-content details summary:hover {
  color: var(--primary);
}

/* Navegación del aula */
.lesson-nav {
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.step-btn {
  transition: background .15s, border-color .15s, color .15s;
}

.step-btn:hover {
  border-color: var(--primary);
}

/* Escritorios con poca anchura */
@media (min-width: 1101px) and (max-width: 1450px) {
  .learn {
    grid-template-columns: 220px minmax(0, 1fr) minmax(0, 1.05fr);
  }

  .learn-content {
    padding: 24px 22px 36px;
  }

  .work-body {
    padding: 16px;
  }

  .code-editor {
    font-size: .81rem;
  }
}

/* Tablet */
@media (max-width: 1100px) {
  .learn-content {
    padding: 24px;
  }

  .learn-work {
    border-left: 1px solid var(--border);
  }

  .editor-wrap {
    min-height: 320px;
  }
}

/* Móvil */
@media (max-width: 860px) {
  .learn-content {
    padding: 20px 16px 30px;
  }

  .learn-work {
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .work-body {
    padding: 14px;
    gap: 14px;
  }

  .work-head {
    min-height: 50px;
    padding: 10px 14px;
  }

  .work-foot {
    padding: 12px;
    gap: 7px;
  }

  .work-foot .btn {
    flex: 1 1 auto;
  }

  .editor-wrap {
    min-height: 300px;
  }

  .code-editor {
    min-height: 260px;
    font-size: .78rem;
  }

  .code-editor .gutter {
    min-width: 40px;
    padding-left: 5px;
    padding-right: 8px;
  }

  .code-editor pre,
  .code-editor textarea {
    padding-left: 12px;
    padding-right: 12px;
  }

  .task {
    padding: 18px;
  }

  .task h2 {
    font-size: 1.15rem;
  }

  .console-body {
    max-height: 190px;
  }
}

@media (max-width: 520px) {
  .editor-tabs button {
    padding: 0 10px;
    font-size: .73rem;
  }

  .editor-tabs .lang {
    padding: 0 5px;
    font-size: .65rem;
  }

  .work-foot .btn {
    min-width: 100%;
  }

  .match-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* =========================================================
   CODELEARN GTAHUB — FASE 2.4: IDE INTERACTIVO
   ========================================================= */

.code-editor {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.editor-toolbar {
  min-height: 38px;
  padding: 4px 9px;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
  background: #172338;
  border-bottom: 1px solid #334155;
  color: #cbd5e1;
  font-family: var(--font);
  font-size: 12px;
}

.editor-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.editor-tools button {
  min-width: 29px;
  height: 27px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #dbeafe;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.editor-tools button:hover {
  background: #334155;
  border-color: #475569;
  color: #fff;
}

.editor-toolbar-separator {
  width: 1px;
  height: 18px;
  margin: 0 3px;
  background: #475569;
}

.editor-toolbar-feedback {
  color: #86efac;
  font-size: 11px;
}

.editor-cursor {
  display: flex;
  gap: 12px;
  color: #94a3b8;
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}

.code-editor .scroller,
.code-editor .gutter,
.code-editor textarea,
.code-editor pre {
  font-size: var(--editor-font-size, 14px);
}

.run-status {
  margin-left: auto;
  margin-right: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: #94a3b8;
}

.run-status[data-state="running"],
.run-status[data-state="loading"] {
  color: #fbbf24;
}

.run-status[data-state="success"] {
  color: #4ade80;
}

.run-status[data-state="error"] {
  color: #f87171;
}

@media (max-width: 600px) {
  .editor-toolbar {
    gap: 5px;
    padding: 5px 7px;
  }

  .editor-tools {
    gap: 2px;
  }

  .editor-tools button {
    padding: 0 6px;
  }

  .editor-toolbar-feedback {
    display: none;
  }

  .editor-cursor {
    gap: 7px;
    font-size: 10px;
  }

  .run-status {
    font-size: 10px;
  }
}

/* ─── FASE 2.5: experiencia de aprendizaje ─────────────────────────────── */

/* Progreso individual de las unidades */
.idx-unit {
  display: block;
  padding-bottom: 8px;
}

.idx-unit-progress {
  margin: 7px 18px 3px;
}

.idx-unit-progress-label,
.course-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.72rem;
}

.idx-unit-progress-label strong,
.course-progress-label strong {
  color: var(--primary-700);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.idx-unit-progress-track {
  height: 5px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.idx-unit-progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
  transition: width 0.3s ease;
}

/* Progreso general del curso */
.course-progress {
  margin: 16px 0 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.course-progress .progress {
  margin-top: 8px;
}

/* Navegación entre lecciones */
.lesson-nav {
  align-items: stretch;
  flex-wrap: wrap;
}

.lesson-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  max-width: 48%;
  white-space: normal;
  text-align: left;
}

.lesson-nav-link span {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.lesson-nav-link small {
  font-size: 0.7rem;
  font-weight: 500;
  opacity: 0.75;
}

.lesson-nav-link strong {
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.lesson-nav-locked,
.lesson-nav-end {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.lesson-nav-locked {
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
}

/* Estado activo de los controles móviles */
.mobile-switch button.is-active {
  color: var(--primary-700);
  border-color: var(--primary);
  background: var(--primary-50);
  font-weight: 700;
}

.mobile-switch button:focus-visible,
.lesson-nav a:focus-visible {
  outline: 3px solid var(--primary-100);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .mobile-switch {
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  }

  .learn-content {
    padding: 18px 14px 28px;
  }

  .course-progress {
    margin-top: 14px;
  }

  .lesson-nav {
    gap: 8px;
  }

  .lesson-nav-link {
    max-width: calc(50% - 4px);
    min-height: 48px;
    padding: 9px 10px;
  }

  .lesson-nav-link strong {
    font-size: 0.76rem;
  }
}

@media (max-width: 520px) {
  .lesson-nav-link {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .lesson-nav-end,
  .lesson-nav-locked {
    width: 100%;
  }

  .course-progress {
    padding: 10px 12px;
  }
}

/* Dashboard personalizado: objetivos y certificados */
.weekly-goal-card .card-head h3,
.card .card-head h3 .i {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.weekly-goals {
  display: flex;
  flex-direction: column;
  gap: 17px;
}

.weekly-goal {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border);
}

.weekly-goal:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.weekly-goal > p {
  margin: 0;
}

.certificate-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 17px;
}

.certificate-total {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--primary-50);
}

.certificate-total strong {
  color: var(--primary);
  font-size: 1.65rem;
  font-weight: 800;
}

.certificate-total span {
  color: var(--muted);
  font-size: .76rem;
}

.certificate-total.pending {
  background: #f5faf9;
}

.certificate-total.pending strong {
  color: var(--accent);
}

.pending-certificates {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pending-certificates h4 {
  margin: 0;
  font-size: .88rem;
}

.pending-certificate {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.pending-certificate .grow {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.pending-certificate .grow strong {
  font-size: .85rem;
}

.pending-certificate .grow span {
  color: var(--muted);
  font-size: .75rem;
}

.pending-certificate > .i {
  color: var(--muted);
  flex-shrink: 0;
}

@media (max-width: 560px) {
  .certificate-summary {
    gap: 8px;
  }

  .certificate-total {
    padding: 12px;
  }
}

/* =========================================================
   LABORATORIO DE PROGRAMACIÓN
   ========================================================= */
.lab-page { gap: 20px; }
.lab-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.lab-heading h1 { margin: 4px 0 6px; }
.lab-heading p { margin: 0; }
.lab-heading .eyebrow {
  color: var(--primary);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .09em;
}
.lab-layout {
  display: grid;
  grid-template-columns: minmax(210px, 250px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.lab-sidebar { position: sticky; top: 82px; }
.lab-sidebar h3 { margin: 0; }
.lab-project-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  margin-top: 8px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.lab-project-item:hover,
.lab-project-item.active {
  border-color: var(--primary);
  background: var(--surface-2, #f1f5f9);
}
.lab-project-item span { font-weight: 700; overflow-wrap: anywhere; }
.lab-project-item small { color: var(--muted); }
.lab-no-projects { line-height: 1.5; }
.lab-workspace { display: grid; gap: 16px; min-width: 0; }
.lab-editor-card { padding: 0; overflow: hidden; }
.lab-project-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.lab-project-name { max-width: 360px; min-width: 180px; }
.lab-actions { flex-wrap: wrap; }
.lab-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px 0;
  background: #111a2e;
  overflow-x: auto;
}
.lab-tab {
  padding: 10px 14px;
  border: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: .8rem;
}
.lab-tab.active {
  background: #0f172a;
  color: #fff;
  box-shadow: inset 0 2px var(--primary);
}
.lab-editor-container { background: #0f172a; overflow: auto; }
.lab-editor-container .code-editor { min-height: 380px; }
.lab-preview-card { overflow: hidden; }
.lab-panel-heading { margin-bottom: 12px; }
.lab-panel-heading h3 { margin: 0; display: flex; gap: 8px; align-items: center; }
.lab-preview {
  min-height: 260px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.lab-preview .preview-frame {
  display: block;
  width: 100%;
  height: 420px;
  border: 0;
  border-radius: 0;
}
.lab-preview-empty {
  min-height: 260px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #64748b;
  text-align: center;
}
.lab-console { min-width: 0; }
.lab-console header { gap: 12px; }
.lab-console .console-title { display: flex; gap: 8px; align-items: center; }
.lab-console .console-body { min-height: 80px; max-height: 260px; }

@media (max-width: 850px) {
  .lab-layout { grid-template-columns: 1fr; }
  .lab-sidebar { position: static; }
  .lab-project-toolbar { align-items: stretch; }
  .lab-project-name { max-width: none; width: 100%; }
  .lab-actions { justify-content: flex-start; }
}

/* Centro de comunicaciones */
.announcement { border: 1px solid var(--border, #e5e7eb); }
.announcement.featured { border-left: 4px solid var(--primary); }
.announcement.read { opacity: .82; }
.announcement h2 { margin: 14px 0 8px; }
.announcement-body { white-space: pre-wrap; line-height: 1.7; overflow-wrap: anywhere; }
.announcement-preview { padding: 18px; }
.announcement-preview-item { display:flex; align-items:center; gap:12px; padding:12px 0; color:inherit; text-decoration:none; border-top:1px solid var(--border, #e5e7eb); }
.announcement-preview-item .grow { min-width:0; display:grid; gap:4px; }
.announcement-preview-item .grow span { color:var(--muted, #64748b); font-size:.88rem; }
.announcement-dot { width:9px; height:9px; flex:0 0 9px; border-radius:50%; background:var(--primary); }
.announcement-dot.seen { background:#a1a1aa; }

/* Centro de comunicaciones */
.announcement { border: 1px solid var(--border, #e5e7eb); }
.announcement.featured { border-left: 4px solid var(--primary); }
.announcement.read { opacity: .82; }
.announcement h2 { margin: 14px 0 8px; }
.announcement-body { white-space: pre-wrap; line-height: 1.7; overflow-wrap: anywhere; }
.announcement-preview { padding: 18px; }
.announcement-preview-item { display:flex; align-items:center; gap:12px; padding:12px 0; color:inherit; text-decoration:none; border-top:1px solid var(--border, #e5e7eb); }
.announcement-preview-item .grow { min-width:0; display:grid; gap:4px; }
.announcement-preview-item .grow span { color:var(--muted, #64748b); font-size:.88rem; }
.announcement-dot { width:9px; height:9px; flex:0 0 9px; border-radius:50%; background:var(--primary); }
.announcement-dot.seen { background:#a1a1aa; }

/* CODELEARN ACADEMIC STUDY WEEK */
.study-week-card {
  min-width: 0;
}

.study-week-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
}

.study-week-summary > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.study-week-summary strong {
  font-size: 1.65rem;
  line-height: 1.2;
  color: var(--text, #172033);
}

.study-week-summary span {
  font-size: .78rem;
  color: var(--muted, #64748b);
}

.study-week-summary .study-week-target {
  text-align: right;
}

.study-week-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
  margin-top: 18px;
}

.study-day {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  color: var(--muted, #64748b);
}

.study-day > span {
  font-size: .7rem;
  text-transform: capitalize;
}

.study-day i {
  display: block;
  width: 100%;
  max-width: 34px;
  aspect-ratio: 1;
  border-radius: 9px;
  background: #edf0f4;
  border: 1px solid #e2e8f0;
}

.study-day.level-1 i { background: #d1fae5; border-color: #a7f3d0; }
.study-day.level-2 i { background: #86efac; border-color: #4ade80; }
.study-day.level-3 i { background: #4ade80; border-color: #22c55e; }
.study-day.level-4 i { background: #15803d; border-color: #166534; }

.study-day.today > span {
  color: var(--text, #172033);
  font-weight: 700;
}

.study-day.today i {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.study-day small {
  font-size: .68rem;
  white-space: nowrap;
}

.study-week-note {
  margin: 14px 0 0;
  line-height: 1.5;
}

@media (max-width: 420px) {
  .study-week-calendar { gap: 3px; }
  .study-day > span, .study-day small { font-size: .62rem; }
}

/* Codelearn — expediente académico */
.academic-profile {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.academic-profile-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.academic-profile-kpis > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 16px;
  border: 1px solid var(--border, #e6e9ef);
  border-radius: 12px;
  background: var(--surface-2, #f7f8fa);
}

.academic-profile-kpis strong {
  font-size: 1.55rem;
  line-height: 1.2;
  font-weight: 750;
}

.academic-profile-kpis span,
.academic-profile-bottom span,
.academic-certificates .list-item span:not(.kpi-icon) {
  color: var(--muted, #747b88);
  font-size: .82rem;
}

.academic-study {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border, #e6e9ef);
  border-radius: 12px;
}

.academic-study-bars {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  align-items: end;
  gap: 8px;
  min-height: 112px;
}

.academic-study-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-width: 0;
  height: 100%;
}

.academic-study-track {
  display: flex;
  align-items: end;
  width: 100%;
  height: 82px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-2, #f0f2f5);
}

.academic-study-track span {
  display: block;
  width: 100%;
  min-height: 2px;
  border-radius: 6px;
  background: var(--primary);
}

.academic-study-day small {
  color: var(--muted, #747b88);
  font-size: .72rem;
}

.academic-profile-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border, #e6e9ef);
}

.academic-profile-bottom > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.academic-profile-bottom a {
  font-weight: 650;
  text-decoration: none;
}

.academic-certificates {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.academic-certificates .list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border, #e6e9ef);
}

.academic-certificates .list-item:last-child {
  border-bottom: 0;
}

.academic-certificates .list-item .grow {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

@media (max-width: 700px) {
  .academic-profile-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .academic-study-bars {
    gap: 4px;
  }

  .academic-study {
    padding: 12px;
  }
}

/* ─── Identidad corporativa oficial Codelearn ─── */
.codelearn-logo {
  display: block;
  flex: 0 0 auto;
  max-width: 100%;
  object-fit: contain;
}

.sidebar .brand {
  min-height: 48px;
  align-items: center;
}

.sidebar .brand .codelearn-logo {
  width: 148px;
  height: auto;
}

.auth-side .auth-brand {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
}

.auth-side .auth-brand .codelearn-logo {
  width: 148px;
  height: auto;
}

.btn-primary,
button.primary,
.button-primary {
  background-color: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-primary:hover,
button.primary:hover,
.button-primary:hover {
  background-color: var(--primary-700);
  border-color: var(--primary-700);
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--brand-text);
  outline-offset: 3px;
}

/* ─── Codelearn · Paleta oficial extraída del logotipo ─── */
.nav a.active {
  background: var(--primary-50);
  color: var(--primary);
}

.nav a.active .i,
.brand-text span {
  color: var(--brand-text);
}

.btn-primary,
button.primary,
.button-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover,
button.primary:hover,
.button-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.progress-fill,
.progress-bar > span {
  background: var(--brand);
}

::selection {
  background: var(--brand-lime);
  color: var(--primary);
}
