/* ══ SIDEBAR ═══════════════════════════════════════════════ */
/* Inserted between drawer and header. mainLayout wraps sidebar + mainContent */

#mainLayout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#mainContent {
  flex: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
}

/* ── Sidebar ── */
#mainSidebar {
  width: 220px;
  min-width: 220px;
  height: 100%;
  background: linear-gradient(180deg, #1a1145 0%, #0f0a24 100%);
  border-right: 1px solid rgba(124,58,237,.18);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 220ms cubic-bezier(.4,0,.2,1), min-width 220ms cubic-bezier(.4,0,.2,1);
  z-index: 100;
  font-family: 'Nunito', sans-serif;
}

#mainSidebar.collapsed {
  width: 58px;
  min-width: 58px;
}

/* ── Sidebar header ── */
.sb-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  min-height: 56px;
}

#mainSidebar.collapsed .sb-header {
  justify-content: center;
  padding: 12px 0;
}

.sb-logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
}
.sb-logo img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.sb-brand {
  font-weight: 900;
  font-size: 15px;
  color: #f0ecff;
  letter-spacing: -.02em;
}

.sb-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,.2);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 150ms;
}
.sb-toggle:hover { color: rgba(255,255,255,.5); }

#mainSidebar.collapsed .sb-brand,
#mainSidebar.collapsed .sb-toggle { display: none; }

/* ── Nav items ── */
.sb-nav {
  padding: 10px 8px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.sb-nav-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  color: rgba(240,236,255,.78);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 3px;
  transition: all 150ms;
  text-align: left;
}

.sb-nav-btn:hover {
  background: rgba(124,58,237,.08);
  color: rgba(240,236,255,.95);
}

.sb-nav-btn.active {
  background: rgba(124,58,237,.14);
  border-color: rgba(124,58,237,.22);
  color: #c4b5fd;
}

.sb-nav-btn .sb-icon {
  font-size: 17px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.sb-nav-btn .sb-label { white-space: nowrap; }

#mainSidebar.collapsed .sb-nav-btn {
  justify-content: center;
  padding: 10px 0;
}
#mainSidebar.collapsed .sb-nav-btn .sb-label { display: none; }

/* ── Divider ── */
.sb-divider {
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: 8px 12px;
}

/* ── Subject selector ── */
.sb-section-title {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.50);
  letter-spacing: .08em;
  padding: 0 12px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.sb-subject-select {
  width: calc(100% - 16px);
  margin: 0 8px;
  padding: 7px 10px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  color: #f0ecff;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.sb-subject-select option {
  background: #1a1145;
  color: #f0ecff;
}

#mainSidebar.collapsed .sb-subject-wrap { display: none; }
#mainSidebar.collapsed .sb-subject-icon {
  display: flex;
  justify-content: center;
  font-size: 20px;
  padding: 4px 0;
}

/* ── Quick stats ── */
.sb-stats {
  margin-top: 12px;
  padding: 0 8px;
}

.sb-stats-card {
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 10px;
  padding: 9px 12px;
}

.sb-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
}

.sb-stat-label {
  font-size: 11.5px;
  color: rgba(255,255,255,.4);
}

.sb-stat-val {
  font-size: 12.5px;
  font-weight: 800;
}

#mainSidebar.collapsed .sb-stats { display: none; }

/* ── Profile footer ── */
.sb-profile {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.sb-profile:hover { background: rgba(255,255,255,.03); }

.sb-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg,#6d28d9,#4c1d95);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #e9d5ff;
  flex-shrink: 0;
}

.sb-profile-name { font-size: 13px; font-weight: 700; color: #f0ecff; }
.sb-profile-sub { font-size: 11px; color: rgba(255,255,255,.55); }
.sb-profile-info { flex: 1; min-width: 0; }

#mainSidebar.collapsed .sb-profile {
  justify-content: center;
  padding: 12px 0;
}
#mainSidebar.collapsed .sb-profile-info { display: none; }

/* ── Hide sidebar on very small screens, show hamburger instead ── */
@media(max-width:768px) {
  #mainSidebar { display: none; }
}

/* ══ PHASE 2: INPUT BAR SIMPLIFICATION ══════════════════════ */
/* Hide elements that moved to sidebar or are replaced by new chips */

/* Hide course toggle (2º Bach / 1º Bach) — now in sidebar subject selector */
#subjectBar > div:first-child { display: none !important; }

/* Hide dynamic subject buttons — now in sidebar */
#subjectBtns { display: none !important; }

/* Hide katex hint — redundant */
#katexHint { display: none !important; }

/* Hide the old 6-button mode bar — replaced by 3 quick chips */
.mode-bar { display: none !important; }

/* Fix: subject-bar overflow clips the tools dropdown */
#subjectBar { overflow: visible !important; }

/* ── Tools dropdown ── */
.tools-dropdown-wrap {
  position: relative;
}

.tools-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  min-width: 240px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  z-index: 50;
}
.tools-dropdown.show { display: block; }

.tools-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--text);
  transition: background 100ms;
}
.tools-dropdown-item:hover { background: #f5f3ff; }
.tools-dropdown-item .td-icon { font-size: 18px; width: 24px; text-align: center; }
.tools-dropdown-item .td-label { font-size: 13px; font-weight: 700; }
.tools-dropdown-item .td-sub { font-size: 11px; color: var(--muted); }

/* ── Quick action chips (below input) ── */
.quick-chips {
  display: flex;
  gap: 7px;
  margin-top: 7px;
  overflow-x: auto;
  scrollbar-width: none;
}
.quick-chips::-webkit-scrollbar { display: none; }

.qchip {
  font-size: .72rem;
  font-weight: 700;
  padding: .3rem .75rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  flex-shrink: 0;
  font-family: inherit;
}
.qchip:hover {
  border-color: var(--p2);
  color: var(--p);
  background: rgba(124,58,237,.04);
}

/* ── Plus button in input row ── */
.tools-toggle-btn {
  width: 44px;
  height: 44px;
  background: #faf5ff;
  border: 1.5px solid #c4b5fd;
  border-radius: 10px;
  color: var(--p);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .2s;
  font-weight: 700;
}
.tools-toggle-btn:hover { background: var(--p); color: #fff; border-color: var(--p); }
.tools-toggle-btn.active { background: var(--p); color: #fff; border-color: var(--p); }

/* ══ PHASE 3: DRAWER CLEANUP ══════════════════════════════ */
/* Hide items that now live in sidebar or tools menu */

/* Hide: Calendario, Noticias, Libros, Películas, Resumir, Flashcards, Mapa mental,
   Podcast, Sala de Ideas, Verificar noticia, Mr. Ego, Esquema, Examen, Ranking,
   Acciones rápidas, Temas de estudio, Profile stats, Limpiar, Tienda, Skillback, Grupo */

/* DESCUBRIR section title */
#drawerDescubrir { display: none !important; }

/* CREAR section title */
#drawerCrear { display: none !important; }

/* Calendario link */
.drawer-body > a[href="/estudio"] { display: none !important; }

/* Noticias */
.drawer-body > button[onclick*="openNews"] { display: none !important; }

/* Libros/Películas wrapper */
#drawerCultura { display: none !important; }

/* Resumir apuntes */
.drawer-body > button[onclick*="openResumenes"] { display: none !important; }

/* Flashcards/Mindmap wrapper */
#drawerFlashMind { display: none !important; }

/* Podcast, Sala de Ideas, Factcheck */
.drawer-body > button[onclick*="openPodcast"] { display: none !important; }
.drawer-body > button[onclick*="openSalaIdeas"] { display: none !important; }
.drawer-body > button[onclick*="openFactcheck"] { display: none !important; }

/* Skillback agent link */
.drawer-body > a[onclick*="openSkillbackAgent"] { display: none !important; }

/* Profile stats card in drawer */
.drawer-profile { display: none !important; }

/* Esquema, Examen, Ranking items */
#modeBtn-esquema { display: none !important; }
.drawer-body .d-item[onclick*="openExam"] { display: none !important; }
.drawer-body .d-item[onclick*="openRanking"] { display: none !important; }

/* Acciones rápidas + Temas de estudio (collapsible sections) */
#hdr-acc, #body-acc, #hdr-temas, #body-temas { display: none !important; }

/* Limpiar conversación */
.drawer-body .d-item.danger { display: none !important; }

/* Skillback SSO, Grupo de estudio, Tienda */
.drawer-body .d-item[onclick*="openSkillbackSSO"] { display: none !important; }
.drawer-body .d-item[onclick*="openGrupo"] { display: none !important; }
.drawer-body .d-item[onclick*="openShop"] { display: none !important; }

/* Hide excessive dividers (most items above are hidden) */
.drawer-body .d-div { display: none !important; }

/* Show remaining items: Historial, Mis exámenes, Referidos, Gestionar sub, Cerrar sesión */
.drawer-body .d-item[onclick*="openHistorial"] { display: flex !important; }
.drawer-body .d-item[onclick*="openExamHistorial"] { display: flex !important; }
.drawer-body .d-item[onclick*="openReferral"] { display: flex !important; }
#manageSubBtn { /* keep existing display logic via JS */ }
#drawerLogoutBtn { /* keep existing display logic via JS */ }

/* ══ PHASE 3B: SHARE ROW SIMPLIFICATION ═══════════════════ */
/* Hide WA, IG, and Grupo buttons — keep only Copiar + Esquema PDF */
.share-row .share-btn[onclick*="shareWhatsApp"] { display: none !important; }
.share-row .share-btn[onclick*="shareInstagram"] { display: none !important; }
.share-row .share-btn[onclick*="openGrupo"],
.share-row .share-btn.gp-share { display: none !important; }

/* ══ PHASE 4: DARK MODE ═══════════════════════════════════ */
[data-theme="dark"] {
  --bg: #0f0e18 !important;
  --card: #1a1832 !important;
  --border: rgba(255,255,255,.08) !important;
  --text: #f0ecff !important;
  --muted: rgba(255,255,255,.45) !important;
  --shadow: 0 4px 24px rgba(0,0,0,.4) !important;
}

[data-theme="dark"] header {
  background: linear-gradient(135deg, #1a0a3e, #2d1b69) !important;
}

[data-theme="dark"] .input-area {
  background: rgba(15,14,24,.95) !important;
  border-top-color: rgba(255,255,255,.06) !important;
}

[data-theme="dark"] #userInput {
  background: rgba(255,255,255,.05) !important;
  border-color: rgba(255,255,255,.1) !important;
  color: #f0ecff !important;
}

[data-theme="dark"] .chat-msgs {
  background: #0f0e18 !important;
}

[data-theme="dark"] .msg-bubble,
[data-theme="dark"] .bubble {
  background: #1a1832 !important;
  border-color: rgba(124,58,237,.12) !important;
  color: #f0ecff !important;
}

[data-theme="dark"] .welcome {
  color: #f0ecff !important;
}
[data-theme="dark"] .welcome h2 {
  color: #c4b5fd !important;
}
[data-theme="dark"] .welcome p {
  color: rgba(255,255,255,.5) !important;
}

[data-theme="dark"] .wc-card {
  border-color: rgba(255,255,255,.1) !important;
}
[data-theme="dark"] .wc-purple {
  background: linear-gradient(135deg, rgba(124,58,237,.2), rgba(109,40,217,.1)) !important;
  color: #c4b5fd !important;
}
[data-theme="dark"] .wc-orange {
  background: linear-gradient(135deg, rgba(245,158,11,.15), rgba(217,119,6,.08)) !important;
  color: #fbbf24 !important;
}
[data-theme="dark"] .wc-cyan {
  background: linear-gradient(135deg, rgba(6,182,212,.15), rgba(14,116,144,.08)) !important;
  color: #67e8f9 !important;
}

[data-theme="dark"] .share-btn {
  border-color: rgba(255,255,255,.1) !important;
  color: rgba(255,255,255,.4) !important;
}
[data-theme="dark"] .share-btn:hover {
  background: rgba(124,58,237,.15) !important;
  color: #c4b5fd !important;
}

[data-theme="dark"] .qchip {
  border-color: rgba(255,255,255,.1) !important;
  color: rgba(255,255,255,.45) !important;
}
[data-theme="dark"] .qchip:hover {
  border-color: rgba(124,58,237,.3) !important;
  color: #c4b5fd !important;
  background: rgba(124,58,237,.1) !important;
}

[data-theme="dark"] .tools-dropdown {
  background: #1a1832 !important;
  border-color: rgba(255,255,255,.1) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,.5) !important;
}
[data-theme="dark"] .tools-dropdown-item {
  color: #f0ecff !important;
}
[data-theme="dark"] .tools-dropdown-item:hover {
  background: rgba(124,58,237,.15) !important;
}
[data-theme="dark"] .tools-dropdown-item .td-sub {
  color: rgba(255,255,255,.4) !important;
}

[data-theme="dark"] .tools-toggle-btn {
  background: rgba(124,58,237,.15) !important;
  border-color: rgba(124,58,237,.3) !important;
  color: #c4b5fd !important;
}

[data-theme="dark"] .upload-btn {
  background: rgba(124,58,237,.12) !important;
  border-color: rgba(124,58,237,.25) !important;
  color: #c4b5fd !important;
}

[data-theme="dark"] .paywall-banner {
  background: rgba(124,58,237,.15) !important;
  color: #c4b5fd !important;
}

/* ══ PHASE 5: PRICING SIMPLIFICATION ══════════════════════ */
/* Hide Ecosistema plan — merged conceptually with Familia */
.plan-card[style*="border-color:rgba(251,191,36"] { display: none !important; }

/* Hide packs by default — shown via toggle */
.pricing-packs-section { display: none; }
.pricing-packs-section.show { display: block; }

/* Toggle link for packs */
.pricing-packs-toggle {
  display: block;
  text-align: center;
  margin-top: 1rem;
  font-size: .82rem;
  font-weight: 700;
  color: var(--p);
  cursor: pointer;
  padding: .6rem;
  border: 1.5px solid rgba(124,58,237,.2);
  border-radius: 10px;
  background: rgba(124,58,237,.04);
  transition: all .15s;
}
.pricing-packs-toggle:hover {
  background: rgba(124,58,237,.1);
}

/* ══ PHASE 5B: CLASES PARTICULARES SOCIAL PROOF ═══════════ */
/* Enhance existing professor cards with better visual hierarchy */
.prof-card {
  padding: 1.1rem 1.2rem !important;
}

.prof-card .prof-bio {
  background: rgba(255,255,255,.03) !important;
  padding: .5rem .7rem !important;
  border-radius: 8px !important;
  border-left: 2px solid rgba(167,139,250,.3) !important;
  margin-top: .6rem !important;
}

/* ══ PHASE 6: HEADER CLEANUP (desktop only) ═══════════════ */
/* On desktop (sidebar visible), hide redundant header elements */
@media(min-width:769px) {
  /* Hamburger + logo → already in sidebar */
  .hamburger { display: none !important; }
  .logo-area { display: none !important; }

  /* XP badge → already in sidebar stats */
  .xp-badge { display: none !important; }

  /* Grupo button → in sidebar nav (Progreso) */
  #grupoHeaderBtn { display: none !important; }

  /* Clases button → in sidebar nav (Clases) */
  #clasesHeaderBtn { display: none !important; }

  /* Make header more compact on desktop */
  header {
    min-height: 42px !important;
    padding: 0 1rem !important;
  }

  .hdr-left {
    min-width: 0 !important;
    flex: 0 !important;
  }

  .hdr-center {
    flex: 1 !important;
    justify-content: flex-start !important;
    gap: .6rem !important;
  }
}

/* ══ VIEW SYSTEM ═══════════════════════════════════════════ */
#mainViewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.app-view {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  display: none;
}

.app-view.is-active {
  display: block;
}

#view-chat.is-active {
  display: block;
  height: 100%;
}

#view-chat #appShell {
  height: 100%;
}

#view-progreso,
#view-practicar {
  background: #0d0c15;
  color: #f0ecff;
  padding: 28px 36px;
}

/* ══ PROGRESO PANEL ═══════════════════════════════════════ */

.prog-inner {
  max-width: 860px;
  margin: 0 auto;
}

.prog-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #f0ecff;
  margin: 0 0 22px 0;
}

/* Summary card */
.prog-summary {
  background: linear-gradient(135deg, rgba(124,58,237,.1), rgba(16,185,129,.06));
  border: 1px solid rgba(124,58,237,.22);
  border-radius: 15px;
  padding: 22px 28px;
  margin-bottom: 20px;
}

.prog-stats-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.prog-stat {
  text-align: center;
  min-width: 75px;
}

.prog-stat-icon { font-size: 1.2rem; }
.prog-stat-val { font-size: 1.2rem; font-weight: 900; margin-top: 3px; }
.prog-stat-label { font-size: .68rem; color: rgba(255,255,255,.35); margin-top: 2px; }

.prog-level-row {
  display: flex;
  justify-content: space-between;
  font-size: .72rem;
  margin: 16px 0 5px;
}
.prog-level-text { color: rgba(255,255,255,.45); }
.prog-level-pct { color: #c4b5fd; font-weight: 700; }

.prog-level-bar {
  height: 5px;
  background: rgba(255,255,255,.07);
  border-radius: 3px;
}
.prog-level-fill {
  height: 100%;
  background: linear-gradient(90deg,#7c3aed,#a855f7);
  border-radius: 3px;
  transition: width 600ms;
}

/* Grid 2 columns */
.prog-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

/* Cards */
.prog-card {
  background: rgba(255,255,255,.025);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 13px;
  padding: 16px 18px;
}
.prog-card-full {
  margin-bottom: 18px;
}

.prog-card-title {
  font-size: .85rem;
  font-weight: 700;
  color: rgba(255,255,255,.45);
  margin: 0 0 12px 0;
}

.prog-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.prog-card-header .prog-card-title { margin: 0; }

/* Calendar Heatmap */
.prog-cal-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 4px;
}
.prog-cal-header span {
  font-size: .6rem;
  color: rgba(124,58,237,.5);
  text-align: center;
  font-weight: 700;
}
.prog-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  position: relative;
}
.prog-cal-day {
  aspect-ratio: 1;
  border-radius: 4px;
  background: rgba(124,58,237,.06);
  border: 1px solid rgba(124,58,237,.08);
  transition: transform .15s, box-shadow .15s, background .3s;
  cursor: pointer;
  position: relative;
}
.prog-cal-day:hover {
  transform: scale(1.25);
  box-shadow: 0 2px 8px rgba(124,58,237,.3);
  z-index: 2;
}
.prog-cal-day.level-1 { background: rgba(124,58,237,.18); border-color: rgba(124,58,237,.12); }
.prog-cal-day.level-2 { background: rgba(124,58,237,.35); border-color: rgba(124,58,237,.25); }
.prog-cal-day.level-3 { background: rgba(124,58,237,.55); border-color: rgba(124,58,237,.4); }
.prog-cal-day.level-4 { background: rgba(124,58,237,.8); border-color: rgba(124,58,237,.6); }
.prog-cal-day.active { background: rgba(124,58,237,.5); border-color: rgba(124,58,237,.35); }
.prog-cal-day.today {
  border: 2px solid #7c3aed;
  box-shadow: 0 0 8px rgba(124,58,237,.3);
}
@keyframes calFadeIn {
  from { opacity: 0; transform: scale(.5); }
  to { opacity: 1; transform: scale(1); }
}
.prog-cal-day.animate {
  animation: calFadeIn .3s ease forwards;
  opacity: 0;
}

/* Missions */
.prog-missions-count {
  font-size: .8rem;
  font-weight: 800;
  color: #c4b5fd;
}

.prog-mission {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.prog-mission-last { border-bottom: none; }

.prog-mission-check { font-size: .9rem; }
.prog-mission-text {
  flex: 1;
  font-size: .8rem;
  color: #f0ecff;
}
.prog-mission.done .prog-mission-text {
  color: rgba(255,255,255,.35);
  text-decoration: line-through;
}
.prog-mission-xp {
  font-size: .72rem;
  font-weight: 700;
  color: #34d399;
}

.prog-mission-cta {
  width: 100%;
  margin-top: 10px;
  background: rgba(124,58,237,.1);
  border: 1px solid rgba(124,58,237,.22);
  border-radius: 8px;
  padding: 7px;
  color: #c4b5fd;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* Ranking */
.prog-ranking-pos {
  font-size: .78rem;
  font-weight: 700;
  color: #c4b5fd;
}

.prog-ranking-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 7px;
  margin-bottom: 3px;
}
.prog-ranking-row.you {
  background: rgba(124,58,237,.08);
  border: 1px solid rgba(124,58,237,.15);
}
.prog-ranking-medal { font-size: .85rem; width: 22px; text-align: center; }
.prog-ranking-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg,#7c3aed,#6d28d9);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 800; color: #e9d5ff;
}
.prog-ranking-name { flex: 1; font-size: .8rem; color: rgba(255,255,255,.6); }
.prog-ranking-row.you .prog-ranking-name { color: #f0ecff; font-weight: 800; }
.prog-ranking-xp { font-size: .78rem; font-weight: 700; color: #c4b5fd; min-width: 50px; text-align: right; }
.prog-ranking-empty, .prog-group-empty {
  font-size: .8rem; color: rgba(255,255,255,.3); padding: 12px 0; text-align: center;
}

/* Logros */
.prog-logros {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.prog-logro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.05);
  text-align: center;
}
.prog-logro-icon { font-size: 1.3rem; }
.prog-logro-text { font-size: .68rem; color: rgba(255,255,255,.5); }
.prog-logro-locked { opacity: .4; }
.prog-logro-unlocked {
  opacity: 1;
  background: rgba(124,58,237,.08);
  border-color: rgba(124,58,237,.2);
}
.prog-logro-unlocked .prog-logro-text { color: #c4b5fd; }

/* Subject stats */
.prog-subject-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.prog-subject-name {
  font-size: .82rem;
  font-weight: 700;
  color: #f0ecff;
  width: 100px;
  flex-shrink: 0;
}
.prog-subject-bar {
  flex: 1;
  height: 5px;
  background: rgba(255,255,255,.06);
  border-radius: 3px;
}
.prog-subject-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 600ms;
}
.prog-subject-pct {
  font-size: .75rem;
  color: rgba(255,255,255,.35);
  width: 34px;
  text-align: right;
}
.prog-subject-nota {
  font-size: .82rem;
  font-weight: 800;
  min-width: 28px;
  text-align: right;
}

/* Study group card */
.prog-group-card {
  background: linear-gradient(135deg, rgba(16,185,129,.07), rgba(5,150,105,.03));
  border: 1px solid rgba(16,185,129,.2);
  border-radius: 14px;
  padding: 18px 22px;
  margin-bottom: 22px;
}
.prog-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.prog-group-title {
  font-size: .95rem;
  font-weight: 800;
  color: #f0ecff;
}
.prog-group-sub {
  font-size: .75rem;
  color: rgba(255,255,255,.4);
}
.prog-group-invite {
  margin-left: auto;
  background: rgba(16,185,129,.15);
  border: 1px solid rgba(16,185,129,.3);
  border-radius: 8px;
  padding: 5px 14px;
  color: #34d399;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.prog-group-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 7px;
  margin-bottom: 3px;
}
.prog-group-row.you {
  background: rgba(124,58,237,.08);
  border: 1px solid rgba(124,58,237,.15);
}

/* Dark mode overrides for views */
[data-theme=dark] #view-progreso {
  background: #0d0c15;
}
[data-theme=dark] #view-practicar {
  background: #0d0c15;
}

/* Responsive: stack on mobile */
@media(max-width:768px) {
  #view-progreso { padding: 18px 14px; }
  .prog-grid-2 { grid-template-columns: 1fr; }
  .prog-logros { grid-template-columns: 1fr 1fr; }
}

/* ══ PRACTICAR PANEL ══════════════════════════════════════ */
.pract-inner { max-width: 860px; margin: 0 auto; }
.pract-title { font-size: 1.35rem; font-weight: 800; color: #f0ecff; margin: 0 0 3px 0; }
.pract-sub { font-size: .82rem; color: rgba(255,255,255,.35); margin: 0 0 22px 0; }

/* 2x2 grid of action cards (matching reference) */
.pract-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin-bottom: 26px;
}

.pract-card {
  background: rgba(255,255,255,.025);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 13px;
  padding: 18px 20px;
  cursor: pointer;
  transition: all 180ms;
}
.pract-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124,58,237,.3);
}
.pract-card-highlight {
  background: rgba(124,58,237,.07);
  border-color: rgba(124,58,237,.22);
}
.pract-card-icon { font-size: 1.6rem; margin-bottom: 8px; }
.pract-card-title { font-size: .92rem; font-weight: 800; color: #f0ecff; margin-bottom: 3px; }
.pract-card-sub { font-size: .75rem; color: rgba(255,255,255,.35); margin-bottom: 12px; }
.pract-card-btn {
  font-size: .78rem; font-weight: 700;
  padding: 6px 14px;
  border-radius: 7px;
  background: rgba(124,58,237,.12);
  border: 1px solid rgba(124,58,237,.22);
  display: inline-block;
}

/* Podcast */
.pract-podcast {
  background: linear-gradient(135deg, rgba(124,58,237,.08), rgba(168,85,247,.04));
  border: 1px solid rgba(124,58,237,.2);
  border-radius: 14px;
  padding: 18px 22px;
  margin-bottom: 26px;
}
.pract-podcast-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.pract-podcast-title { font-size: .95rem; font-weight: 800; color: #f0ecff; }
.pract-podcast-sub { font-size: .75rem; color: rgba(255,255,255,.4); }
.pract-podcast-badge {
  margin-left: auto;
  font-size: .62rem; font-weight: 700;
  background: rgba(124,58,237,.25); color: #c4b5fd;
  border-radius: 4px; padding: 2px 8px;
}
.pract-podcast-cta {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 10px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  cursor: pointer; transition: all 150ms;
}
.pract-podcast-cta:hover {
  border-color: rgba(124,58,237,.3);
  background: rgba(124,58,237,.08);
}
.pract-podcast-play {
  width: 36px; height: 36px; border-radius: 8px;
  background: rgba(124,58,237,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; color: #fff; flex-shrink: 0;
}

/* ══ Por materia (grid de chips por materia del tutor activo) ══════════ */
/* Variable --c que se inyecta inline desde populatePracticar() con el
   color de acento del tutor (window.__TUTOR_ACTIVE.accent). */
.pract-mat-title {
  font-size: .82rem; font-weight: 700;
  color: rgba(240,236,255,.62);
  margin: 4px 0 12px 0;
  letter-spacing: .01em;
}
.pract-mat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 26px;
}
.pract-mat-card {
  background: rgba(255,255,255,.025);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 12px;
  padding: 12px 13px 11px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: border-color 180ms, transform 180ms, box-shadow 180ms;
}
.pract-mat-card:hover {
  transform: translateY(-1px);
  border-color: var(--c, rgba(124,58,237,.4));
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
}
.pract-mat-head {
  display: flex; align-items: center; gap: 9px;
  cursor: pointer;
  padding: 1px 2px;
}
.pract-mat-emoji { font-size: 1.35rem; line-height: 1; }
.pract-mat-name {
  font-size: .82rem; font-weight: 800;
  color: var(--c, #f0ecff);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pract-mat-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
}
.pract-mat-btn {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07);
  color: rgba(240,236,255,.78);
  border-radius: 7px;
  padding: 6px 0;
  font-size: .68rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 150ms;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pract-mat-btn:hover {
  background: var(--c, rgba(124,58,237,.18));
  border-color: var(--c, rgba(124,58,237,.4));
  color: #fff;
}

/* CTA para tutores con UI dedicada (Pipo/Fiti/Nora/Mentor) — sustituye
   el grid de chips por un mensaje + botón que abre la app real. */
.pract-dedicated-cta {
  background: linear-gradient(135deg, rgba(255,255,255,.025), rgba(255,255,255,.01));
  border: 1px solid rgba(255,255,255,.07);
  border-left: 3px solid var(--c, #7c3aed);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 26px;
  cursor: pointer;
  transition: border-color 180ms, transform 180ms;
}
.pract-dedicated-cta:hover {
  transform: translateY(-1px);
  border-color: var(--c, rgba(124,58,237,.5));
}
.pract-dedicated-btn {
  margin-top: 12px;
  border: 0;
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 800;
  font-size: .82rem;
  cursor: pointer;
  font-family: inherit;
}

/* History */
.pract-hist-title {
  font-size: .88rem; font-weight: 700;
  color: rgba(255,255,255,.4); margin: 0 0 12px 0;
}
.pract-hist-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px; margin-bottom: 5px;
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.04);
  cursor: pointer;
}
.pract-hist-row:hover { border-color: rgba(124,58,237,.15); }
.pract-hist-type { font-size: .82rem; font-weight: 700; color: #f0ecff; }
.pract-hist-topic { font-size: .82rem; color: rgba(255,255,255,.35); flex: 1; }
.pract-hist-score { font-size: .82rem; font-weight: 700; }
.pract-hist-date { font-size: .72rem; color: rgba(255,255,255,.2); }
.pract-hist-empty {
  font-size: .82rem; color: rgba(255,255,255,.3);
  text-align: center; padding: 20px 0;
}

@media(max-width:768px) {
  #view-practicar { padding: 18px 14px; }
  .pract-grid { grid-template-columns: 1fr 1fr; }
}
.sb-nav-btn:is(a) { color: rgba(240,236,255,.78); }
.sb-nav-btn:is(a):hover { color: rgba(240,236,255,.95); }
