:root {
  /* Paleta de marca "Tech Premium" (ver Estudio de mercado y diseño) */
  --azul-noche: #1e3a8a;
  --morado-electrico: #6d5df6;
  --verde: #22c55e;
  --blanco-roto: #f8fafc;
  --gris-antracita: #111827;

  --bg: var(--blanco-roto);
  --panel: #ffffff;
  --panel-alt: #f1f3fb;
  --border: #e2e6f0;
  --text: var(--gris-antracita);
  --text-muted: #5b6478;
  --primary: var(--morado-electrico);
  --primary-dark: #5645d9;
  --primary-tint: #f0edfe;
  --accent: var(--azul-noche);
  --danger: #dc2626;
  --danger-bg: #fdecec;
  --warning: #c2860a;
  --warning-bg: #fdf3e0;
  --success: var(--verde);
  --success-bg: #e7f9ee;
  --success-text: #15803d;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.05);
  --shadow-md: 0 10px 24px -8px rgba(30, 58, 138, 0.18), 0 2px 6px rgba(17, 24, 39, 0.06);
  --gradient-brand: linear-gradient(135deg, var(--azul-noche) 0%, var(--morado-electrico) 100%);
  --gradient-dark: linear-gradient(160deg, #0b1220 0%, #16234f 45%, var(--azul-noche) 100%);
  font-size: 16px;
}

/* --- Tema oscuro --- */
html[data-theme="oscuro"] {
  --bg: #0a0e1a;
  --panel: #121a2e;
  --panel-alt: #1a2440;
  --border: #263153;
  --text: #e7ebf7;
  --text-muted: #8b93b0;
  --primary: #8f7bff;
  --primary-dark: #6d5df6;
  --primary-tint: #1e1b4a;
  --accent: #5b8cff;
  --danger: #f87171;
  --danger-bg: #3a1a1f;
  --warning: #fbbf24;
  --warning-bg: #3a2e10;
  --success: #4ade80;
  --success-bg: #12301f;
  --success-text: #4ade80;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 24px -8px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 10% 0%, rgba(109, 93, 246, 0.07), transparent 45%),
    radial-gradient(circle at 90% 10%, rgba(30, 58, 138, 0.06), transparent 40%);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

html[data-theme="oscuro"] body {
  background-image:
    radial-gradient(circle at 10% 0%, rgba(109, 93, 246, 0.12), transparent 45%),
    radial-gradient(circle at 90% 10%, rgba(91, 140, 255, 0.10), transparent 40%);
}

#app.app-shell { min-height: 100vh; display: flex; align-items: stretch; }

/* --- Sidebar / marca (tema claro) --- */

.sidebar {
  display: flex;
  flex-direction: column;
  width: 250px;
  flex-shrink: 0;
  padding: 20px 14px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  padding: 4px 10px 20px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.brand-mark { flex-shrink: 0; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(109, 93, 246, 0.25)); }
.brand-text {
  display: inline-flex;
  flex-direction: row;
  align-items: baseline;
  line-height: 1.15;
  font-family: 'Sora', 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand-opo { color: var(--text); }
.brand-study {
  background: linear-gradient(135deg, #1E3A8A, #6D5DF6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--text-muted);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 0.89rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--primary-tint); color: var(--primary-dark); }
.nav-link.active { background: var(--primary-tint); color: var(--primary-dark); font-weight: 700; }
.nav-link.active:hover { background: var(--primary-tint); }
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 3px;
  background: var(--primary);
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; transition: opacity 0.15s ease; }
.nav-link:hover .nav-icon, .nav-link.active .nav-icon { opacity: 1; }

.nav-group { display: flex; flex-direction: column; }
.nav-submenu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 2px 21px;
  padding-left: 13px;
  border-left: 1px solid var(--border);
}
.nav-submenu .nav-link { font-size: 0.83rem; padding: 7px 12px; }
.nav-submenu .nav-icon { width: 15px; height: 15px; }

.nav-divider { height: 1px; background: var(--border); margin: 10px 8px; flex-shrink: 0; }

.plan-pro-widget {
  display: block;
  margin-top: 14px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--gradient-brand);
  color: #fff;
  flex-shrink: 0;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.plan-pro-widget:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.plan-pro-icono { font-size: 1.2rem; margin-bottom: 4px; }
.plan-pro-titulo { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; color: #fff; }
.plan-pro-texto { font-size: 0.76rem; opacity: 0.9; line-height: 1.4; color: #fff; }

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-user { color: var(--text-muted); font-size: 0.85rem; padding: 4px 10px; }
.nav-logout { cursor: pointer; color: var(--text-muted); text-decoration: none; padding: 8px 10px; border-radius: 10px; font-size: 0.88rem; transition: background 0.15s ease, color 0.15s ease; }
.nav-logout:hover { background: var(--panel-alt); color: var(--text); }

/* --- Columna principal (topbar + contenido) --- */

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 40px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.search-wrap { position: relative; flex: 1; max-width: 420px; }
.search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); opacity: 0.45; font-size: 0.9rem; pointer-events: none; }
.search-input { padding-left: 36px; padding-right: 44px; background: var(--panel-alt); border-color: transparent; }
.search-input:focus { background: var(--panel); border-color: var(--primary); }
.search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  pointer-events: none;
  line-height: 1.2;
}
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 340px;
  overflow-y: auto;
  z-index: 30;
  display: none;
}
.search-results.visible { display: block; }
.search-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.87rem;
  color: var(--text);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.activo { background: var(--primary-tint); }
.search-result-item .num { color: var(--primary); font-weight: 700; flex-shrink: 0; }
.search-empty { padding: 14px; color: var(--text-muted); font-size: 0.85rem; }

.topbar-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.streak-badge {
  background: var(--success-bg);
  color: var(--success-text);
  font-weight: 700;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.bell-btn {
  position: relative;
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  font-size: 1.05rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.bell-btn:hover { background: var(--panel-alt); }
.bell-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
.profile-chip { display: flex; align-items: center; gap: 9px; }
.profile-avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--gradient-brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  flex-shrink: 0;
}
.profile-greeting { display: flex; flex-direction: column; line-height: 1.15; }
.profile-hello { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.profile-sub { font-size: 0.72rem; color: var(--text-muted); }

main#view { padding: 32px 40px 64px; max-width: 1180px; width: 100%; margin: 0 auto; }

.sidebar.sidebar-min { width: 84px; align-items: center; }
.sidebar.sidebar-min .brand { padding: 4px 0 20px; border-bottom: none; }
.sidebar.sidebar-min .brand-text { display: none; }
.sidebar.sidebar-min .nav { display: none !important; }
.sidebar.sidebar-min .plan-pro-widget, .sidebar.sidebar-min .nav-divider { display: none !important; }

@media (max-width: 860px) {
  #app.app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    flex-direction: row;
    align-items: center;
    padding: 10px 16px;
    overflow-x: auto;
    overflow-y: visible;
  }
  .brand { border-bottom: none; border-right: 1px solid var(--border); margin: 0 10px 0 0; padding: 0 14px 0 0; }
  .nav { flex-direction: row; flex: 0 0 auto; gap: 4px; }
  .nav-link span { display: none; }
  .nav-group { flex-direction: row; align-items: center; gap: 4px; }
  .nav-submenu { flex-direction: row; margin: 0; padding-left: 4px; border-left: 1px solid var(--border); }
  .nav-divider { width: 1px; height: 24px; margin: 0 4px; }
  .plan-pro-widget { display: none; }
  .sidebar-footer { flex-direction: row; align-items: center; margin: 0 0 0 10px; padding: 0 0 0 10px; border-top: none; border-left: 1px solid var(--border); }
  .topbar-row { padding: 10px 18px; flex-wrap: wrap; }
  .search-wrap { max-width: none; order: 3; flex: 1 1 100%; }
  main#view { padding: 24px 18px 48px; }
}

h1 {
  font-family: 'Sora', 'Inter', sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
h2 {
  font-family: 'Sora', 'Inter', sans-serif;
  font-size: 1.12rem;
  font-weight: 600;
  margin: 24px 0 10px;
}
p.subtitle { color: var(--text-muted); margin: 0 0 26px; font-size: 0.96rem; }

/* --- Tarjetas / paneles --- */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 28px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient-brand);
  opacity: 0.85;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.card .num { font-family: 'Sora', sans-serif; font-size: 1.9rem; font-weight: 700; color: var(--text); }
.card .label { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }
.card .card-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  margin-bottom: 12px;
}

.card.accent-success::before { background: linear-gradient(135deg, #4ade80, var(--verde)); }
.card.accent-warning::before { background: linear-gradient(135deg, #fbbf24, #c2860a); }
.card.accent-primary::before { background: var(--gradient-brand); }
.card.accent-accent::before { background: linear-gradient(135deg, var(--azul-noche), var(--morado-electrico)); }

.card.accent-success .card-icon { background: #dcfce7; }
.card.accent-warning .card-icon { background: #fef3c7; }
.card.accent-primary .card-icon { background: #dbeafe; }
.card.accent-accent .card-icon { background: #ede9fe; }

/* --- Inicio: tarjetas KPI (racha, estudio de hoy, temas completados, nivel) --- */

.kpi-progreso-barra { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 10px; }
.kpi-progreso-barra-fill { height: 100%; border-radius: 999px; background: var(--gradient-brand); }
.card.kpi-nivel-card { display: flex; align-items: center; gap: 16px; }
.kpi-ring {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(var(--primary) calc(var(--pct, 0) * 1%), var(--border) 0);
}
.kpi-ring-inner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
}
.kpi-nivel-info .num { font-size: 1.05rem; }
.kpi-nivel-info .label { margin-top: 2px; }

/* Versión compacta/minimalista de las 4 tarjetas KPI principales de Inicio:
   fuente más pequeña que en el resto de tarjetas de la app (p.ej. las de
   Comunidad), para que el bloque se sienta más ligero. */
.cards-kpi-inicio { gap: 12px; margin-bottom: 24px; }
.cards-kpi-inicio .card { padding: 14px 16px; }
.cards-kpi-inicio .card .card-icon { width: 30px; height: 30px; font-size: 0.9rem; margin-bottom: 8px; }
.cards-kpi-inicio .card .num { font-size: 1.3rem; }
.cards-kpi-inicio .card .label { font-size: 0.72rem; margin-top: 2px; }

/* KPIs de Estadísticas: versión reducida y minimalista, con los iconos en
   gris (sin fondo de color ni barra superior de color) para que el foco esté
   en el número, no en el icono. */
.cards-kpi-stats { gap: 12px; margin-bottom: 20px; }
.cards-kpi-stats .card { padding: 14px 16px; }
.cards-kpi-stats .card::before { background: var(--border); opacity: 1; }
.cards-kpi-stats .card .card-icon {
  width: 28px;
  height: 28px;
  font-size: 0.85rem;
  margin-bottom: 8px;
  background: var(--panel-alt);
  filter: grayscale(1) opacity(0.75);
}
.cards-kpi-stats .card .num { font-size: 1.3rem; }
.cards-kpi-stats .card .label { font-size: 0.72rem; margin-top: 2px; }
.cards-kpi-inicio .kpi-progreso-barra { margin-top: 8px; height: 5px; }
.cards-kpi-inicio .kpi-ring { width: 52px; height: 52px; }
.cards-kpi-inicio .kpi-ring-inner { width: 38px; height: 38px; font-size: 0.72rem; }
.cards-kpi-inicio .kpi-nivel-info .num { font-size: 0.95rem; }

.kpi-racha-sparkline { display: block; margin-top: 8px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.bloque-titulo {
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 0.98rem;
  margin: 28px 0 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  color: var(--text);
}

/* --- Temario: bloques plegables (acordeón) --- */

.bloques-acordeon { display: flex; flex-direction: column; gap: 10px; }
.bloque-acordeon-header {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 14px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}
.bloque-acordeon-header:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.bloque-acordeon-chevron {
  color: var(--primary);
  font-weight: 700;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.bloque-acordeon-header.abierto .bloque-acordeon-chevron { transform: rotate(90deg); }
.bloque-acordeon-titulo { font-family: 'Sora', sans-serif; font-weight: 600; font-size: 0.96rem; flex: 1; }
.bloque-acordeon-progreso {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--panel-alt);
  border: 1px solid var(--border);
  padding: 3px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.bloque-acordeon-body { margin-top: 8px; margin-left: 4px; }
.bloque-acordeon-body.colapsado { display: none; }

.tema-list { display: flex; flex-direction: column; gap: 6px; }
.tema-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.tema-row:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); transform: translateX(2px); }
.tema-row .titulo { font-size: 0.93rem; flex: 1; }
.tema-row .num { font-family: 'Sora', sans-serif; font-weight: 700; color: var(--primary); min-width: 34px; }

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.disponible { background: var(--success-bg); color: var(--success-text); }
.badge.pendiente { background: var(--warning-bg); color: var(--warning); }

/* --- Botones --- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: var(--gradient-brand);
  color: #ffffff;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease, filter 0.15s ease;
  text-decoration: none;
}
.btn:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); filter: brightness(1.03); }
.btn.secondary { background: var(--panel-alt); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--primary-tint); border-color: var(--primary); }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn.dice { background: var(--panel); border: 1.5px dashed var(--primary); color: var(--primary); }
.btn.dice:hover { background: var(--primary-tint); }

select, input[type=text], input[type=password], input[type=date], input[type=number], textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s ease;
}
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--primary); }

.resumen-content { line-height: 1.68; font-size: 0.98rem; }
.resumen-content h2 { border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.resumen-content table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 0.9rem; }
.resumen-content th, .resumen-content td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.resumen-content th { background: var(--panel-alt); }
.resumen-content ul { padding-left: 22px; }

.timer {
  font-variant-numeric: tabular-nums;
  font-family: 'Sora', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  background: var(--panel-alt);
  border: 1px solid var(--border);
}
.timer.warning { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.timer.critical { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

.exam-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }

textarea.editor { min-height: 420px; resize: vertical; font-size: 1rem; line-height: 1.55; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.dropzone:hover { border-color: var(--primary); color: var(--primary); background: var(--panel-alt); }

.foto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.foto-item { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.foto-item img { width: 100%; height: 140px; object-fit: cover; display: block; }
.foto-item button {
  position: absolute; top: 4px; right: 4px;
  background: rgba(11, 16, 32, 0.65); color: #fff; border: none;
  border-radius: 6px; width: 24px; height: 24px; cursor: pointer;
}

table.historial { width: 100%; border-collapse: collapse; }
table.historial th { text-align: left; padding: 10px 12px; font-size: 0.82rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 2px solid var(--border); }
table.historial td { text-align: left; padding: 12px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
table.historial tr:hover td { background: var(--panel-alt); cursor: pointer; }

.nota-pill {
  display: inline-block; padding: 4px 13px; border-radius: 999px; font-weight: 700; font-size: 0.85rem;
}
.nota-alta { background: var(--success-bg); color: var(--success-text); }
.nota-media { background: var(--warning-bg); color: var(--warning); }
.nota-baja { background: var(--danger-bg); color: var(--danger); }

.evaluacion-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .evaluacion-grid { grid-template-columns: 1fr; } }

.lista-puntos { padding-left: 20px; margin: 6px 0; }
.lista-puntos li { margin-bottom: 6px; }

.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.92rem; border: 1px solid transparent; }
.alert.error { background: var(--danger-bg); color: #9c1d31; border-color: rgba(224, 69, 90, 0.25); }
.alert.info { background: var(--primary-tint); color: var(--primary-dark); border-color: rgba(109, 93, 246, 0.25); }
.alert.success { background: var(--success-bg); color: #0f7a38; border-color: rgba(22, 163, 74, 0.2); }
html[data-theme="oscuro"] .alert.error { color: #fca5b1; }
html[data-theme="oscuro"] .alert.info { color: #c7bdff; }
html[data-theme="oscuro"] .alert.success { color: #86efac; }

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

.modo-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .modo-choice { grid-template-columns: 1fr; } }
.modo-card {
  border: 2px solid var(--border); border-radius: var(--radius); padding: 24px; text-align: center; cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  background: var(--panel);
}
.modo-card .emoji { font-size: 1.6rem; }
.modo-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.modo-card.selected { border-color: var(--primary); box-shadow: var(--shadow-md); background: var(--primary-tint); }
.modo-card h3 { font-family: 'Sora', sans-serif; margin: 10px 0 6px; font-size: 1.02rem; }
.modo-card p { color: var(--text-muted); font-size: 0.88rem; margin: 0; }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }
.field .hint { color: var(--text-muted); font-size: 0.82rem; margin-top: 4px; }

.back-link { display: inline-block; margin-bottom: 14px; color: var(--text-muted); text-decoration: none; font-size: 0.88rem; }
.back-link:hover { color: var(--primary); }

/* --- Sorteo aleatorio --- */

.sorteo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.sorteo-resultado {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--panel-alt);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.92rem;
  animation: fadeIn 0.25s ease;
}
.sorteo-resultado strong { color: var(--primary-dark); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* --- El preparador (chat por tema) --- */

.chat-panel { border-top: 3px solid transparent; border-image: var(--gradient-brand) 1; }
.chat-header { margin-bottom: 16px; }
.chat-header h2 { font-family: 'Sora', sans-serif; }

.chat-mensajes {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 16px;
}

.chat-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.93rem;
  line-height: 1.55;
  animation: fadeIn 0.2s ease;
}
.chat-msg-autor { font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 4px; opacity: 0.7; }
.chat-msg-texto p:first-child { margin-top: 0; }
.chat-msg-texto p:last-child { margin-bottom: 0; }

.chat-msg.user {
  align-self: flex-end;
  background: var(--gradient-brand);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.chat-msg.user .chat-msg-autor { color: rgba(255, 255, 255, 0.75); }

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.chat-msg.assistant .chat-msg-autor { color: var(--primary); }

.chat-pensando .chat-msg-texto { color: var(--text-muted); font-style: italic; }

.chat-form textarea.chat-input { min-height: 64px; resize: vertical; font-size: 0.93rem; }

/* --- Widget flotante: El preparador --- */

.preparador-flotante {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: 'Inter', sans-serif;
}

.preparador-boton {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--gradient-brand);
  color: #ffffff;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  position: relative;
  transition: transform 0.15s ease;
}
.preparador-boton:hover { transform: scale(1.06); }

.preparador-boton-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ff5470;
  border: 2px solid #ffffff;
}

.preparador-burbuja {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 14px 16px;
  position: relative;
  animation: fadeIn 0.25s ease;
}
.preparador-burbuja-icono { font-size: 1.25rem; line-height: 1; }
.preparador-burbuja-texto { margin: 0 0 8px; font-size: 0.87rem; line-height: 1.45; color: var(--text); }
.preparador-burbuja-cerrar {
  position: absolute;
  top: 6px;
  right: 8px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px;
}
.preparador-burbuja-cerrar:hover { color: var(--text); }

.preparador-panel {
  width: 340px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: fadeIn 0.2s ease;
}

.preparador-panel-header {
  background: var(--gradient-brand);
  color: #ffffff;
  padding: 12px 16px;
  font-weight: 700;
  font-family: 'Sora', sans-serif;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.preparador-panel-cerrar {
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}
.preparador-panel-cerrar:hover { background: rgba(255, 255, 255, 0.3); }

.preparador-panel-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 0;
  margin-bottom: 0;
  max-height: none;
}

.preparador-panel-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.preparador-panel-form textarea {
  flex: 1;
  min-height: 40px;
  max-height: 90px;
  resize: vertical;
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 8px 10px;
  font-family: inherit;
}
.preparador-panel-form textarea:focus { outline: none; border-color: var(--primary); }
.preparador-panel-form .btn { align-self: flex-end; }

@media (max-width: 520px) {
  .preparador-flotante { right: 12px; bottom: 12px; }
  .preparador-panel { width: calc(100vw - 24px); }
  .preparador-burbuja { max-width: calc(100vw - 90px); }
}

/* --- Suscripción --- */

.suscripcion-actual-panel { border-top: 3px solid transparent; border-image: var(--gradient-brand) 1; }

.suscripcion-actual-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.suscripcion-badge-plan {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
  font-family: 'Sora', sans-serif;
  background: var(--primary-tint);
  color: var(--primary-dark);
}
.suscripcion-badge-plan.plan-pro { background: var(--gradient-brand); color: #fff; }
.suscripcion-badge-plan.plan-premium { background: linear-gradient(135deg, #1a1330 0%, #7c3aed 60%, #c026d3 100%); color: #fff; }

.suscripcion-fechas {
  display: flex;
  gap: 32px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.suscripcion-fecha-item { display: flex; flex-direction: column; gap: 2px; }
.suscripcion-fecha-label { font-size: 0.76rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.suscripcion-fecha-valor { font-weight: 700; font-family: 'Sora', sans-serif; }

.planes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 20px;
  align-items: stretch;
}

.plan-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.plan-card.destacado {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.plan-card.actual { border-color: var(--primary-dark); background: var(--primary-tint); }

.plan-card-etiqueta {
  position: absolute;
  top: -12px;
  right: 20px;
  background: var(--gradient-brand);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 12px;
  border-radius: 999px;
}

.plan-card-nombre { font-family: 'Sora', sans-serif; margin: 0; }
.plan-card-precio { font-family: 'Sora', sans-serif; font-size: 1.7rem; font-weight: 800; color: var(--primary-dark); }
.plan-card-precio span { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }

.plan-card-caracteristicas {
  list-style: none;
  margin: 4px 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1;
}
.plan-card-caracteristicas li {
  font-size: 0.87rem;
  line-height: 1.4;
  padding-left: 24px;
  position: relative;
}
.plan-card-caracteristicas li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 0;
  color: var(--primary);
  font-weight: 700;
}

.plan-card .btn[disabled] { opacity: 0.6; cursor: default; }

/* --- Popup de selección de plan tras el registro --- */

.plan-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 25, 0.62);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 40px 16px;
  z-index: 1000;
}

.plan-modal {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 32px;
  max-width: 980px;
  width: 100%;
}

.plan-modal h1, .plan-modal p.subtitle { text-align: center; }
.plan-modal .planes-grid { margin-top: 26px; }

/* --- Upsell: funciones de IA bloqueadas para el plan Básico --- */

.upsell-bloqueo {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.upsell-bloqueo-titulo { font-weight: 700; font-family: 'Sora', sans-serif; }
.upsell-bloqueo p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

/* --- Ajustes: selector de tema claro/oscuro --- */

.tema-toggle-panel { padding: 14px; }
.tema-toggle-grupo {
  display: inline-flex;
  gap: 6px;
  background: var(--panel-alt);
  padding: 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.tema-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.tema-toggle-btn:hover { color: var(--text); }
.tema-toggle-btn.activo {
  background: var(--panel);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* --- Inicio: hero banner --- */

.hero-banner {
  background-color: var(--primary-tint);
  background-image: url('/img/hero-banner.png');
  background-size: cover;
  background-position: right center;
  background-repeat: no-repeat;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 34px;
  margin-bottom: 26px;
  min-height: 230px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.hero-text { position: relative; z-index: 2; max-width: 520px; }
.hero-text h1 { color: var(--text); margin-bottom: 6px; }
.texto-degradado {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-text p.subtitle { color: var(--text-muted); margin-bottom: 0; }
.hero-btn-primary { background: var(--gradient-brand); color: #ffffff; }

/* En pantallas estrechas quitamos la ilustración de fondo: no hay espacio
   suficiente para que se vea bien junto al texto y podría restar legibilidad. */
@media (max-width: 860px) {
  .hero-banner { background-image: none; min-height: 0; }
}

/* --- Inicio: acciones rápidas --- */

.acciones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.accion-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.accion-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); border-color: var(--primary); }
.accion-icon { font-size: 1.6rem; margin-bottom: 10px; }
.accion-card h3 { font-family: 'Sora', sans-serif; margin: 0 0 6px; font-size: 1rem; }
.accion-card p { color: var(--text-muted); font-size: 0.86rem; margin: 0; line-height: 1.5; }

/* --- Progreso por bloque: enlace a desglose --- */

.bloque-progreso-card { display: block; text-decoration: none; color: inherit; }
.bloque-progreso-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ver-desglose { font-size: 0.76rem; color: var(--primary); font-weight: 600; white-space: nowrap; opacity: 0; transition: opacity 0.15s ease; }
.bloque-progreso-card:hover .ver-desglose { opacity: 1; }

.sin-resumen-hint { color: var(--text-muted); font-size: 0.82rem; font-style: italic; }

/* --- Progreso por bloque (Inicio) --- */

.bloques-progreso-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.bloque-progreso-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.bloque-progreso-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.bloque-progreso-header h3 {
  font-family: 'Sora', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--text);
}

.progreso-barra {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 14px;
}
.progreso-barra-fill {
  height: 100%;
  background: var(--gradient-brand);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.bloque-progreso-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.bloque-progreso-metrics .metric { display: flex; flex-direction: column; gap: 2px; }
.bloque-progreso-metrics .metric-num { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 1.05rem; color: var(--text); }
.bloque-progreso-metrics .metric-num.muted { color: var(--text-muted); font-weight: 500; }
.bloque-progreso-metrics .metric-label { color: var(--text-muted); font-size: 0.76rem; }
.bloque-progreso-metrics .nota-pill { align-self: flex-start; font-size: 0.8rem; padding: 2px 10px; }

.bloque-progreso-alerta {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: #6b4a05;
  border-left: 3px solid var(--warning);
  font-size: 0.82rem;
  line-height: 1.5;
}

/* --- Inicio: continuar donde lo dejaste --- */

.continuar-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.continuar-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.continuar-icon {
  flex-shrink: 0;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--gradient-brand);
  color: #ffffff;
  font-size: 1.1rem;
}
.continuar-label { font-size: 0.76rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.continuar-titulo { font-family: 'Sora', sans-serif; font-weight: 400; font-size: 0.96rem; margin-top: 2px; }

/* --- Inicio: racha, horas y objetivos --- */

.actividad-panel {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 24px;
  align-items: center;
}
@media (max-width: 780px) {
  .actividad-panel { grid-template-columns: 1fr 1fr; }
  .objetivos-bloque { grid-column: 1 / -1; }
}

.racha-bloque, .horas-bloque { text-align: center; padding: 0 10px; }
.racha-num, .horas-num { font-family: 'Sora', sans-serif; font-size: 1.6rem; font-weight: 700; white-space: nowrap; }
.racha-label, .horas-label { color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; white-space: nowrap; }

.objetivos-bloque { display: flex; flex-direction: column; gap: 14px; min-width: 220px; }
.objetivo-item { display: flex; flex-direction: column; gap: 6px; }
.objetivo-header { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.82rem; color: var(--text-muted); }
.objetivo-valor { font-weight: 700; color: var(--text); }
.objetivo-barra {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  overflow: hidden;
}
.objetivo-barra-fill {
  height: 100%;
  background: var(--gradient-brand);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* --- Inicio: recomendaciones --- */

.recomendaciones-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.recomendacion-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.recomendacion-icono { font-size: 1.5rem; }
.recomendacion-texto h3 { font-family: 'Sora', sans-serif; font-size: 0.96rem; margin: 0 0 4px; }
.recomendacion-texto p { color: var(--text-muted); font-size: 0.85rem; margin: 0; line-height: 1.5; }
.recomendacion-btn { align-self: flex-start; margin-top: auto; }

/* --- Practicar: modo Test (preguntas de opción múltiple) --- */

.test-preguntas { display: flex; flex-direction: column; gap: 22px; }
.test-pregunta { padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.test-pregunta:last-child { border-bottom: none; padding-bottom: 0; }
.test-pregunta-enunciado { font-weight: 600; margin-bottom: 12px; line-height: 1.5; }
.test-opciones { display: flex; flex-direction: column; gap: 8px; }
.test-opcion {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.test-opcion:hover { border-color: var(--primary); background: var(--primary-tint); }
.test-opcion input[type="radio"] { accent-color: var(--primary); flex-shrink: 0; }
.test-opcion span { font-size: 0.94rem; }

/* --- Resultado del test corregido --- */

.test-resultado-lista { display: flex; flex-direction: column; gap: 18px; }
.test-resultado-item {
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
}
.test-resultado-item.acierto { border-left-color: var(--success); background: var(--success-bg); }
.test-resultado-item.fallo { border-left-color: var(--danger); background: var(--danger-bg); }
.test-resultado-item.en-blanco { border-left-color: var(--warning); background: var(--warning-bg); }
.test-resultado-enunciado { font-weight: 600; margin-bottom: 10px; line-height: 1.5; }
.test-resultado-opciones { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; }
.test-resultado-opcion { padding: 7px 12px; border-radius: 8px; font-size: 0.9rem; background: rgba(255, 255, 255, 0.6); }
.test-resultado-opcion.correcta { background: var(--success-bg); color: var(--success-text); font-weight: 600; }
.test-resultado-opcion.marcada-incorrecta { background: var(--danger-bg); color: var(--danger); text-decoration: line-through; }
.test-resultado-estado { font-weight: 700; font-size: 0.85rem; margin-bottom: 6px; }
.test-resultado-explicacion { color: var(--text-muted); font-size: 0.88rem; line-height: 1.5; }

/* --- Planificador --- */

.btn.small { padding: 7px 14px; font-size: 0.82rem; }
.alert.warning { background: var(--warning-bg); color: #6b4a05; border-color: rgba(194, 134, 10, 0.25); }
html[data-theme="oscuro"] .alert.warning { color: #fcd34d; }

.dias-semana-selector { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.dia-semana-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 0 !important;
}
.dia-semana-check input[type="checkbox"] { accent-color: var(--primary); }

.plan-resumen-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 6px; }
.plan-resumen-metrics .metric { display: flex; flex-direction: column; gap: 2px; }
.plan-resumen-metrics .metric-num { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 1.15rem; color: var(--text); }
.plan-resumen-metrics .metric-label { color: var(--text-muted); font-size: 0.76rem; }

.plan-aviso-retraso { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

.plan-config-toggle { margin-bottom: 14px; }

.calendario-panel { padding: 18px 20px 20px; }
.calendario-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.calendario-mes-label {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-transform: capitalize;
}
.calendario-fila-labels {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}
.calendario-label-dia {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}
.calendario-celdas {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendario-dia {
  min-height: 62px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  background: var(--panel);
}
.calendario-dia:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.calendario-dia.vacio { visibility: hidden; cursor: default; border: none; }
.calendario-dia-num { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.calendario-dia.hoy { border-color: var(--primary); background: var(--primary-tint); }
.calendario-dia.hoy .calendario-dia-num { color: var(--primary); }
.calendario-dia.seleccionado { border: 2px solid var(--primary); box-shadow: var(--shadow-md); }
.calendario-dia.dia-examen .calendario-dia-num::after { content: ' 🏁'; }
.calendario-dia.completo { background: var(--success-bg); }
.calendario-dia.atrasado { border-color: var(--danger); }
.calendario-dia.atrasado .calendario-dia-num { color: var(--danger); }
.calendario-dia-badges { display: flex; flex-wrap: wrap; gap: 3px; }
.calendario-badge {
  font-size: 0.68rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  background: var(--panel-alt);
}

.plan-tareas-dia h2 { text-transform: capitalize; font-family: 'Sora', sans-serif; font-size: 1rem; margin: 0 0 14px; }
.plan-tareas-lista { display: flex; flex-direction: column; gap: 10px; }
.tarea-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}
.tarea-item.completada { background: var(--panel-alt); opacity: 0.75; }
.tarea-item.completada .tarea-tema { text-decoration: line-through; }
.tarea-check { display: flex; align-items: center; padding-top: 2px; margin-bottom: 0 !important; }
.tarea-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--success); cursor: pointer; }
.tarea-detalle { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.tarea-tema { font-size: 0.9rem; color: var(--text); }
.tarea-nota { margin: 0; }
.tarea-item > a.btn { align-self: center; flex-shrink: 0; }

.tarea-tipo-badge, .calendario-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}
.tarea-tipo-badge { font-size: 0.76rem; padding: 3px 10px; border-radius: 999px; align-self: flex-start; }

.tipo-estudiar { background: rgba(109, 93, 246, 0.14); color: var(--primary-dark); }
.tipo-repaso { background: var(--warning-bg); color: var(--warning); }
.tipo-test { background: var(--success-bg); color: var(--success-text); }
.tipo-desarrollo { background: rgba(30, 58, 138, 0.14); color: var(--azul-noche); }
.tipo-repaso-general { background: var(--danger-bg); color: var(--danger); }

.ia-badge { background: var(--gradient-brand); color: #ffffff; align-self: flex-start; }

/* ---------------------------------------------------------------------------
   Rediseño: radar de rendimiento, favoritos, quote banner, IA preparador,
   simulacros, comunidad, recursos
--------------------------------------------------------------------------- */

.panel-header-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-header-row h2 { margin: 0; }

.rendimiento-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
@media (min-width: 760px) {
  .rendimiento-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); align-items: center; }
}
.radar-wrap { position: relative; height: 300px; }
.constancia-chart-wrap { position: relative; height: 260px; }
.constancia-toggle { display: flex; gap: 8px; }
.rendimiento-leyenda { display: flex; flex-direction: column; gap: 10px; }
.rendimiento-leyenda-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--panel-alt); font-size: 0.85rem; }
.rendimiento-leyenda-item .nombre { font-weight: 600; color: var(--text); }
.rendimiento-leyenda-item .valor { font-weight: 700; color: var(--primary-dark); }

/* --- Estadísticas: panel "tech dashboard" ---
   Estética fija (oscura, con acentos neón) independiente del selector de
   tema claro/oscuro de Ajustes: buscamos que esta pantalla concreta destaque
   como el "cuadro de mando" tecnológico del opositor. */

.stats-tech {
  position: relative;
  overflow: hidden;
  background: var(--gradient-dark);
  border-radius: 22px;
  padding: 30px clamp(16px, 4vw, 36px) 38px;
  box-shadow: 0 30px 70px -30px rgba(109, 93, 246, 0.5), 0 2px 10px rgba(0, 0, 0, 0.25);
  color: #e7ebf7;
}
.stats-tech::before {
  content: '';
  position: absolute;
  top: -140px;
  right: -110px;
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(143, 123, 255, 0.35), transparent 70%);
  pointer-events: none;
}
.stats-tech::after {
  content: '';
  position: absolute;
  bottom: -160px;
  left: -100px;
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.16), transparent 70%);
  pointer-events: none;
}
.stats-tech > * { position: relative; z-index: 1; }

.stats-tech-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Sora', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #8f7bff;
  background: rgba(143, 123, 255, 0.14);
  border: 1px solid rgba(143, 123, 255, 0.35);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.stats-tech h1 { color: #ffffff; margin-bottom: 4px; }
.stats-tech .subtitle { color: #a7afd6; }

.stats-tech h2 {
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Sora', sans-serif;
}
.stats-tech h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(143, 123, 255, 0.55), transparent);
}

.stats-tech .cards-kpi-stats .card {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(143, 123, 255, 0.22);
  box-shadow: none;
}
.stats-tech .cards-kpi-stats .card::before {
  background: linear-gradient(90deg, #8f7bff, #22d3ee);
  opacity: 0.9;
}
.stats-tech .cards-kpi-stats .card:hover {
  box-shadow: 0 0 0 1px rgba(143, 123, 255, 0.45), 0 16px 34px -14px rgba(109, 93, 246, 0.55);
  transform: translateY(-2px);
}
.stats-tech .cards-kpi-stats .card .card-icon {
  background: rgba(143, 123, 255, 0.16);
  filter: none;
}
.stats-tech .cards-kpi-stats .card .num {
  background: linear-gradient(90deg, #d9d4ff, #8f7bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stats-tech .cards-kpi-stats .card .label { color: #9aa3c9; }

.stats-tech .panel {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(143, 123, 255, 0.2);
  box-shadow: none;
}
.stats-tech .panel h3 { color: #ffffff; }

.stats-tech .rendimiento-leyenda-item { background: rgba(255, 255, 255, 0.05); }
.stats-tech .rendimiento-leyenda-item .nombre { color: #cfd4ec; }
.stats-tech .rendimiento-leyenda-item .valor { color: #c9c0ff; }

.stats-tech .btn.small.secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #cfd4ec;
  border: 1px solid rgba(143, 123, 255, 0.28);
}
.stats-tech .btn.small.secondary:hover { background: rgba(143, 123, 255, 0.18); border-color: #8f7bff; }

.stats-tech .alert.info {
  background: rgba(143, 123, 255, 0.12);
  color: #c7bdff;
  border-color: rgba(143, 123, 255, 0.3);
}

@media (max-width: 640px) {
  .stats-tech { border-radius: 16px; padding: 22px 16px 28px; }
}

.quote-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border-radius: var(--radius);
  background: var(--gradient-brand);
  color: #fff;
  margin-bottom: 24px;
  font-family: 'Sora', sans-serif;
  font-style: italic;
}
.quote-banner .quote-icon { font-size: 1.6rem; font-style: normal; flex-shrink: 0; }

.quote-card-bottom {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px 24px;
  text-align: center;
  margin: 10px 0 28px;
}
.quote-card-bottom .quote-mark { display: block; font-size: 1.7rem; color: var(--text-muted); margin-bottom: 6px; font-family: Georgia, serif; }
.quote-card-bottom p { font-family: 'Sora', sans-serif; font-style: italic; color: var(--text); font-size: 1.05rem; margin: 0; }

/* --- Inicio: filas de dos columnas (Plan de hoy + Preparador; Habilidades + Actividad) --- */
.home-dos-columnas { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 24px; align-items: start; }
@media (min-width: 920px) {
  .home-dos-columnas { grid-template-columns: 1.6fr 1fr; }
}
.home-dos-columnas > .panel { margin-bottom: 0; height: 100%; }

/* --- Favoritos --- */
.fav-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.05rem;
  color: var(--border);
  padding: 2px 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.15s ease, color 0.15s ease;
}
.fav-toggle:hover { transform: scale(1.15); }
.fav-toggle.activo { color: #f59e0b; }
.tema-row { position: relative; }

/* --- Preparador IA (acceso rápido) --- */
.preparador-quick {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.preparador-quick-input-row { display: flex; gap: 10px; flex-wrap: wrap; }
.preparador-quick-input-row select { flex: 1; min-width: 220px; }
.preparador-lista { display: flex; flex-direction: column; gap: 8px; }

.preparador-quick-intro { display: flex; align-items: center; gap: 14px; }
.preparador-quick-icono {
  width: 48px; height: 48px; border-radius: 14px;
  background: var(--gradient-brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.preparador-quick-intro h3 { margin: 0 0 2px; font-size: 1.02rem; }
.preparador-quick-intro p { margin: 0; }
.preparador-quick-selector { display: none; flex-wrap: wrap; }
.preparador-quick-selector.visible { display: flex; }

/* --- Plan de estudio de hoy (Inicio) --- */
.plan-hoy-lista { display: flex; flex-direction: column; gap: 10px; }
.plan-hoy-vacio { color: var(--text-muted); font-size: 0.9rem; }

/* --- Repaso Inteligente (tarjetas estilo Anki) --- */
.repaso-resumen-cards { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.repaso-tema-lista { display: flex; flex-direction: column; gap: 8px; }
.repaso-tema-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel);
}
.repaso-tema-info { display: flex; flex-direction: column; gap: 2px; }
.repaso-tema-titulo { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.repaso-tema-meta { font-size: 0.8rem; color: var(--text-muted); }
.repaso-pendiente-badge { background: var(--success-bg); color: var(--success-text); font-weight: 700; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; }
.repaso-generar-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.repaso-generar-row select { flex: 1; min-width: 220px; }

.flashcard-progreso { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 10px; }
.flashcard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
}
.flashcard-tema-badge { font-size: 0.76rem; color: var(--primary); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.flashcard-pregunta { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 1.15rem; color: var(--text); }
.flashcard-respuesta { color: var(--text); font-size: 0.98rem; line-height: 1.55; border-top: 1px dashed var(--border); padding-top: 16px; width: 100%; }
.flashcard-acciones { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.flashcard-btn-dificil { background: #fee2e2; color: #b91c1c; border: none; }
.flashcard-btn-normal { background: #fef3c7; color: #92400e; border: none; }
.flashcard-btn-facil { background: var(--success-bg); color: var(--success-text); border: none; }

/* --- Ayuda (FAQ) --- */
.ayuda-faq { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.ayuda-item { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel); overflow: hidden; }
.ayuda-pregunta {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  padding: 14px 16px;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ayuda-pregunta:hover { background: var(--panel-alt); }
.ayuda-flecha { transition: transform 0.15s ease; flex-shrink: 0; color: var(--text-muted); }
.ayuda-item.abierto .ayuda-flecha { transform: rotate(180deg); }
.ayuda-respuesta { padding: 0 16px 16px; color: var(--text-muted); font-size: 0.88rem; line-height: 1.55; display: none; }
.ayuda-item.abierto .ayuda-respuesta { display: block; }

/* --- Actividad reciente --- */
.actividad-reciente-lista { display: flex; flex-direction: column; gap: 6px; }
.actividad-reciente-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
}
.actividad-reciente-item:hover { background: var(--panel-alt); }
.act-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  background: var(--primary-tint);
}
.act-icon-test { background: var(--success-bg); }
.act-icon-desarrollo { background: #dbeafe; }
.act-icon-repaso { background: #ede9fe; }
.act-texto { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.actividad-reciente-item .desc { color: var(--text); font-weight: 600; }
.actividad-reciente-item .act-subdesc { color: var(--text-muted); font-size: 0.8rem; }
.actividad-reciente-item .fecha { color: var(--text-muted); font-size: 0.78rem; white-space: nowrap; flex-shrink: 0; }

/* --- Simulacros --- */
.simulacro-opciones { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 16px 0; }
.simulacro-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  background: var(--panel);
}
.simulacro-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.simulacro-card.selected { border-color: var(--primary); background: var(--primary-tint); }
.simulacro-card h3 { margin: 6px 0 4px; font-family: 'Sora', sans-serif; font-size: 0.98rem; }
.simulacro-card p { margin: 0; color: var(--text-muted); font-size: 0.85rem; }
.simulacro-progreso {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--primary-tint);
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 16px;
}
.simulacro-resultado-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.88rem;
}

/* --- Comunidad --- */
.ranking-tabla { width: 100%; border-collapse: collapse; }
.ranking-tabla th, .ranking-tabla td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.ranking-tabla th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.ranking-tabla tr.yo-mismo { background: var(--primary-tint); }
.ranking-pos { font-family: 'Sora', sans-serif; font-weight: 700; color: var(--primary); width: 30px; }
.ranking-pos.top1::before { content: '🥇 '; }
.ranking-pos.top2::before { content: '🥈 '; }
.ranking-pos.top3::before { content: '🥉 '; }

/* --- Recursos --- */
.recursos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.recurso-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.recurso-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.recurso-card .recurso-icon { font-size: 1.4rem; }
.recurso-card h3 { margin: 0; font-family: 'Sora', sans-serif; font-size: 0.98rem; }
.recurso-card p { margin: 0; color: var(--text-muted); font-size: 0.85rem; line-height: 1.45; }
.recurso-card .recurso-categoria { font-size: 0.72rem; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.03em; }
