/* ═══════════════════════════════════════════════
   PORTAL · Enrique Bermúdez Psicología
   Design system — portal.css
   ═══════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Accesibilidad ─────────────────────────── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

html { overscroll-behavior: none; }

:root {
  /* Brand */
  --primary: #4F6D7A;
  --primary-dark: #3C545F;
  --primary-light: #EDF2F4;
  --primary-glow: rgba(79,109,122,.1);
  --secondary: #6B9E8F;
  --accent: #6B9E8F;
  --accent-light: #e8f4ed;

  /* Neutral */
  --bg: #F5F7F8;
  --bg-alt: #EEF2F3;
  --surface: #FFFFFF;
  --text: #1E2A30;
  --text-sec: #4A5A5E;
  --muted: #4A5A5E;
  --border: #DDE3E7;
  --border-light: #EEF1F3;

  /* Status */
  --success: #3A9E6E;
  --success-bg: #e8f4ed;
  --warning: #C48800;
  --warning-bg: #fef9e7;
  --danger: #C0392B;
  --danger-bg: #fdf0ef;

  /* Plan states */
  --pendiente: #8A9AA4;
  --hecho: #3A9E6E;
  --parcial: #E0A020;
  --no_hecho: #C0392B;

  /* Section accent colors */
  --sec-pendiente: #E67E22;
  --sec-pendiente-bg: #FEF5E7;
  --sec-pendiente-border: #F5CBA7;
  --sec-examenes: #E74C3C;
  --sec-examenes-bg: #FDEDEC;
  --sec-examenes-border: #F5B7B1;
  --sec-plan: #3498DB;
  --sec-plan-bg: #EBF5FB;
  --sec-plan-border: #AED6F1;
  --sec-test: #8E44AD;
  --sec-test-bg: #F4ECF7;
  --sec-material: #27AE60;
  --sec-material-bg: #E8F8F0;

  /* Radii */
  --r: 12px;
  --r-sm: 8px;
  --r-btn: 8px;
  --r-lg: 16px;
  --r-pill: 100px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 2px 12px rgba(79,109,122,.08);
  --shadow-md: 0 4px 24px rgba(79,109,122,.12);
  --shadow-hover: 0 6px 24px rgba(79,109,122,.12);
  --shadow-lg: 0 8px 40px rgba(79,109,122,.16);

  /* Layout */
  --header-h: 56px;
  --sidebar-w: 240px;
  --sidebar-w-sm: 64px;
  --sidebar-w-col: 64px;
  --bnav-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* ── ANIMATIONS ──────────────────────────────── */
@keyframes gentleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes dotFill {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes checkPop {
  0% { transform: scale(1); }
  30% { transform: scale(1.3); }
  50% { transform: scale(.9); }
  100% { transform: scale(1); }
}
@keyframes confettiPop {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--cx, 30px), var(--cy, -40px)) scale(0); opacity: 0; }
}
.racha-day__dot--animate {
  animation: dotFill .3s ease backwards;
}
.check-pop { animation: checkPop .4s cubic-bezier(.175,.885,.32,1.275); }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes bubbleIn {
  0% { opacity: 0; transform: scale(.92) translateY(8px); }
  60% { transform: scale(1.02) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 var(--primary-glow); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

/* ── BASE ────────────────────────────────────── */
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── HEADER ──────────────────────────────────── */
.p-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}
.p-header__left {
  display: flex; align-items: center; gap: 12px; min-width: 0;
}
.p-header__logo {
  height: 32px; width: 32px; flex-shrink: 0; border-radius: 6px;
}
.p-header__txt { line-height: 1.15; display: none; }
.p-header__nombre {
  font-size: .92rem; font-weight: 700; color: var(--primary);
  letter-spacing: -.01em; white-space: nowrap;
}
.p-header__rol {
  font-size: .62rem; font-weight: 500; color: var(--muted); display: block;
}
/* Mobile compact title — hidden on desktop, shown on mobile */
.p-header__mobile-title {
  display: block; font-size: .88rem; font-weight: 700; color: var(--primary);
  letter-spacing: -.01em;
}
.p-header__right {
  display: flex; align-items: center; gap: 12px;
}
.p-header__saludo {
  font-size: .82rem; color: var(--muted); white-space: nowrap;
}
.p-header__salir {
  font-size: .78rem; color: var(--muted); text-decoration: none;
  padding: 6px 14px; border: 1px solid var(--border);
  border-radius: var(--r-pill); transition: all .15s;
}
.p-header__salir:hover {
  border-color: var(--primary); color: var(--primary); text-decoration: none;
}

/* Burger */
.p-burger {
  display: flex; background: none; border: none; cursor: pointer;
  padding: 10px; min-height: 44px; min-width: 44px;
  color: var(--text); border-radius: var(--r-sm);
  -webkit-tap-highlight-color: transparent;
  align-items: center; justify-content: center;
}
.p-burger:active { background: var(--primary-light); }
.p-burger svg { display: block; }

/* ── SIDEBAR ─────────────────────────────────── */
.p-sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  position: fixed; top: var(--header-h); bottom: 0; left: 0;
  overflow-y: auto; overflow-x: hidden; z-index: 90;
  transition: transform .25s ease, width .2s ease;
}
.p-nav { padding: 12px 0; display: flex; flex-direction: column; gap: 1px; }

.p-nav__item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; font-size: .86rem; font-weight: 600;
  min-height: 44px;
  color: var(--muted); text-decoration: none;
  border-left: 3px solid transparent;
  transition: all .12s; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.p-nav__item:hover {
  background: var(--primary-light); color: var(--primary); text-decoration: none;
}
.p-nav__item.activo {
  color: var(--primary); border-left-color: var(--primary); background: var(--primary-light);
}
.p-nav__icon { width: 20px; height: 20px; flex-shrink: 0; opacity: .55; }
.p-nav__item.activo .p-nav__icon,
.p-nav__item:hover .p-nav__icon { opacity: 1; }
.p-nav__label { flex: 1; }

.p-nav__sep { height: 1px; background: var(--border-light); margin: 8px 16px; }
.p-nav__group {
  font-size: .6rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); padding: 14px 20px 4px;
}
.p-nav__group-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  padding: 14px 20px 4px;
  opacity: .7;
}

/* Overlay */
.p-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(30,42,48,.45); z-index: 89;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.p-overlay.visible { display: block; }

/* ── LAYOUT ──────────────────────────────────── */
.p-wrap {
  display: flex; min-height: 100vh; min-height: 100dvh;
  padding-top: var(--header-h);
}
.p-content {
  flex: 1; min-width: 0;
  margin-left: var(--sidebar-w);
  padding: 28px 28px 60px;
}
.p-content__inner { max-width: 900px; margin: 0 auto; }

/* ── BOTTOM NAV ──────────────────────────────── */
.p-bnav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--bnav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--border);
  z-index: 100;
}
.p-bnav__inner { display: flex; height: var(--bnav-h); }
.p-bnav__item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px;
  font-size: .72rem; font-weight: 600; color: var(--muted);
  text-decoration: none; position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: color .2s ease, transform .15s ease;
  background: none; border: none; cursor: pointer; font-family: inherit;
}
.p-bnav__item:hover { text-decoration: none; }
.p-bnav__item:active { transform: scale(.9); }
.p-bnav__item.activo { color: var(--primary); }
.p-bnav__item.activo svg { transform: scale(1.1); }
.p-bnav__item.activo::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 32px; height: 3px; background: var(--primary); border-radius: 0 0 3px 3px;
  animation: fadeIn .2s ease;
}
.p-bnav__item svg {
  width: 23px; height: 23px;
  transition: transform .2s ease;
}
.p-bnav__badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: #E74C3C;
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

/* ── WELCOME BANNER ──────────────────────────── */
.p-welcome {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff; border-radius: var(--r-lg); padding: 22px 24px;
  margin-bottom: 24px; position: relative; overflow: hidden;
  animation: fadeInUp .5s ease;
}
.p-welcome::after {
  content: ''; position: absolute; right: -20px; top: -20px;
  width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.p-welcome__greeting {
  font-size: 1.15rem; font-weight: 700; margin-bottom: 4px;
}
.p-welcome__msg {
  font-size: .85rem; opacity: .85; line-height: 1.5;
}
.p-welcome__tip {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.15);
  font-size: .8rem; opacity: .75; line-height: 1.5;
  display: flex; align-items: flex-start; gap: 8px;
}
.p-welcome__tip-icon {
  flex-shrink: 0; width: 16px; height: 16px; opacity: .7; margin-top: 1px;
}

/* ── AI FEEDBACK BUBBLE ─────────────────────── */
.ai-bubble {
  animation: bubbleIn .45s ease;
}

/* ── PAGE HEADER ─────────────────────────────── */
.p-page-head { margin-bottom: 24px; }
.p-page-title { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.p-page-sub { font-size: .88rem; color: var(--muted); margin-top: 4px; }

/* ── CARDS ───────────────────────────────────── */
.p-card {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--r); padding: 16px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .2s ease, transform .2s ease;
}
.p-card:hover { box-shadow: var(--shadow); }
.p-card:active { transform: scale(.985); }
.p-card--lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.p-card--lift:active { transform: translateY(0) scale(.985); }
.p-card--accent { border-left: 4px solid var(--primary); }

/* Animate cards on appear */
.p-card.is-visible,
.doc-card.is-visible,
.bloque-card.is-visible,
.factura-card.is-visible,
.cat-card.is-visible {
  animation: fadeInUp .4s ease backwards;
}

/* ── BUTTONS ─────────────────────────────────── */
.p-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px; border-radius: var(--r-sm);
  font-size: .875rem; font-weight: 700; border: none; cursor: pointer;
  min-height: 44px; text-decoration: none; transition: all .15s;
  -webkit-tap-highlight-color: transparent; font-family: inherit;
}
.p-btn:hover { text-decoration: none; }
.p-btn--primary { background: var(--primary); color: #fff; }
.p-btn--primary:hover { background: var(--primary-dark); }
.p-btn--outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.p-btn--outline:hover { background: var(--primary-light); }
.p-btn--ghost { background: transparent; color: var(--primary); }
.p-btn--ghost:hover { background: var(--primary-light); }
.p-btn--sm { padding: 8px 14px; font-size: .82rem; min-height: 44px; }
.p-btn--pill { border-radius: var(--r-pill); }
.p-btn--block { width: 100%; }
.p-btn--success { background: var(--success); color: #fff; }
.p-btn--warning { background: var(--warning); color: #fff; }
.p-btn--danger  { background: var(--danger); color: #fff; }

/* ── FORMS ───────────────────────────────────── */
.p-field { margin-bottom: 16px; }
.p-label {
  display: block; font-size: .78rem; font-weight: 600;
  color: var(--text-sec); margin-bottom: 6px;
}
.p-input {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: .95rem; color: var(--text); background: var(--bg);
  font-family: inherit;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.p-input:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.p-input::placeholder { color: var(--muted); }
select.p-input { appearance: none; cursor: pointer; }

/* ── ALERTS ──────────────────────────────────── */
.p-alert {
  border-radius: var(--r-sm); padding: 12px 16px;
  font-size: .88rem; line-height: 1.5; margin-bottom: 16px;
}
.p-alert--error { background: var(--danger-bg); border: 1px solid #f5c6c2; color: var(--danger); }
.p-alert--ok    { background: var(--success-bg); border: 1px solid #a8d5b5; color: #2d6a4f; }
.p-alert--warn  { background: var(--warning-bg); border: 1px solid #f9e79f; color: #7d6608; }

/* ── BADGES ──────────────────────────────────── */
.p-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: .72rem; font-weight: 700;
}
.p-badge--pendiente { background: #f0f2f3; color: var(--pendiente); }
.p-badge--hecho     { background: var(--success-bg); color: var(--hecho); }
.p-badge--parcial   { background: var(--warning-bg); color: #8a6d10; }
.p-badge--no_hecho  { background: var(--danger-bg); color: var(--no_hecho); }

/* ── EMPTY STATE ─────────────────────────────── */
.p-empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
}
.p-empty__icon { font-size: 2.8rem; margin-bottom: 16px; opacity: .4; }
.p-empty p { font-size: .9rem; line-height: 1.7; max-width: 300px; margin: 0 auto; }

/* ── SECTION LABEL ───────────────────────────── */
.p-section-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 2px solid var(--border-light);
  display: flex; align-items: center; gap: 8px;
}

/* ── AUTH PAGES (login, recuperar, nueva-password) ── */
.auth-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: 100dvh;
  padding: 24px 20px;
  background: var(--primary);
  overflow: hidden;
}
.auth-body::before {
  content: ''; position: fixed; inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(127,161,167,.25) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(107,158,143,.2) 0%, transparent 50%);
  pointer-events: none;
}
.auth-wrap {
  width: 100%; max-width: 400px; position: relative; z-index: 1;
  animation: authFadeIn .5s ease-out;
}
@keyframes authFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.auth-brand { text-align: center; margin-bottom: 32px; }
.auth-logo {
  height: 80px; width: auto; display: block; margin: 0 auto 14px;
  filter: brightness(0) invert(1); opacity: .92;
}
.auth-appname {
  font-size: .82rem; font-weight: 600; color: rgba(255,255,255,.7);
  letter-spacing: .14em; text-transform: uppercase;
}
.auth-card {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: 0 16px 48px rgba(0,0,0,.18); padding: 36px 32px 32px;
}
.auth-card h2 {
  font-size: 1.3rem; font-weight: 800; margin-bottom: 4px;
  letter-spacing: -.02em;
}
.auth-card .auth-sub { font-size: .88rem; color: var(--muted); margin-bottom: 28px; }
.auth-card .p-field { margin-bottom: 18px; }
.auth-card .p-input {
  padding: 14px 16px; font-size: 1rem; border-radius: var(--r);
  background: var(--bg); border: 1.5px solid var(--border);
}
.auth-card .p-input:focus {
  border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 4px var(--primary-glow);
}
.auth-card .p-btn--primary {
  padding: 14px; font-size: .95rem; border-radius: var(--r);
  min-height: 50px; margin-top: 6px;
  background: var(--primary);
  box-shadow: 0 4px 16px rgba(79,109,122,.3);
  transition: all .2s;
}
.auth-card .p-btn--primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 20px rgba(79,109,122,.4);
  transform: translateY(-1px);
}
.auth-card .p-btn--primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(79,109,122,.3);
}
.auth-links {
  margin-top: 24px; text-align: center;
  display: flex; flex-direction: column; gap: 10px;
}
.auth-links a {
  font-size: .84rem; font-weight: 500; transition: color .15s;
}
.auth-links a.auth-link--sec { font-size: .78rem; color: var(--muted); font-weight: 400; }
.auth-links a.auth-link--sec:hover { color: var(--primary); text-decoration: none; }
.auth-footer {
  margin-top: 28px; text-align: center;
}
.auth-footer a {
  color: rgba(255,255,255,.5); font-size: .8rem; text-decoration: none;
  transition: color .15s;
}
.auth-footer a:hover { color: rgba(255,255,255,.8); text-decoration: none; }

/* Password field wrapper */
.auth-pw-wrap { position: relative; }
.auth-pw-wrap .p-input { padding-right: 48px; }
.auth-pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: 10px;
  color: var(--muted); transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.auth-pw-toggle:hover { color: var(--primary); }
.auth-pw-toggle svg { display: block; }

/* ═══════════ RESPONSIVE ═══════════════════════ */

/* Tablet */
@media (max-width: 1024px) and (min-width: 641px) {
  .p-sidebar { width: var(--sidebar-w-sm); }
  .p-nav__label, .p-nav__group, .p-nav__group-label { display: none; }
  .p-nav__item { padding: 14px; justify-content: center; }
  .p-nav__icon { opacity: .8; }
  .p-content { margin-left: var(--sidebar-w-sm); }
}

/* Mobile */
@media (max-width: 640px) {
  /* burger, txt, mobile-title ya son globales */
  .p-header__saludo { display: none; }

  .p-sidebar { transform: translateX(-100%); width: min(240px, 75vw); }
  .p-sidebar.open { transform: translateX(0); }

  .p-content {
    margin-left: 0;
    padding: 20px 18px calc(var(--bnav-h) + var(--safe-b) + 40px);
  }

  .p-bnav { display: block; }

  /* Bigger typography on mobile */
  .p-page-title { font-size: 1.25rem; }
  .p-page-sub { font-size: .9rem; margin-top: 6px; }
  .docs-header h1, .facturas-header h1 { font-size: 1.25rem; }
  .doc-titulo { font-size: .92rem; }
  .bloque-card__asig { font-size: 1rem; }
  .bloque-card__tarea { font-size: .92rem; }
  .bloque-card__feedback { font-size: .86rem; }

  /* Welcome banner mobile */
  .p-welcome { padding: 20px 20px; border-radius: var(--r); }
  .p-welcome__greeting { font-size: 1.1rem; }

  /* Fix: Bottom nav min height for touch targets */
  .p-bnav__item { min-height: 48px; gap: 4px; }

  /* Fix: Header "Salir" touch target */
  .p-header__salir { min-height: 44px; display: flex; align-items: center; padding: 10px 16px; }

  /* Fix: Inputs prevent iOS zoom + better touch */
  .p-input, input[type="date"], input[type="email"], input[type="text"], input[type="password"], textarea, select {
    font-size: 16px !important;
  }

  /* Fix: Sidebar hardware acceleration */
  .p-sidebar { will-change: transform; }

  /* Fix: Feedback text bigger for readability */
  .bloque-card__feedback { font-size: .92rem; }

  /* Fix: Racha font size */
  .racha-bar__info { font-size: .85rem; }
}

/* Extra small screens */
@media (max-width: 420px) {
  .dash-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .p-content { padding: 16px 14px calc(var(--bnav-h) + var(--safe-b) + 20px); }
  .p-bnav__item { font-size: .62rem; }
}

@media (max-width: 360px) {
  .dash-grid { grid-template-columns: 1fr; }
  .p-bnav__item svg { width: 20px; height: 20px; }
}

/* ═══════════════════════════════════════════════
   PAGE: Mis documentos
   ═══════════════════════════════════════════════ */
.docs-header { margin-bottom: 28px; }
.docs-header h1 { font-size: 1.3rem; font-weight: 800; }
.docs-header p  { color: var(--muted); font-size: .9rem; margin-top: 6px; line-height: 1.5; }

.cats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px; margin-bottom: 32px;
}
.cat-card {
  background: var(--surface); border-radius: var(--r);
  box-shadow: var(--shadow-xs); padding: 20px 14px; text-align: center;
  cursor: pointer; border: 2px solid transparent;
  transition: all .15s; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.cat-card:hover {
  border-color: var(--accent); background: var(--accent-light);
  box-shadow: var(--shadow); transform: translateY(-3px);
  text-decoration: none;
}
.cat-card:active {
  transform: translateY(0) scale(.96);
}
.cat-icono-grande { font-size: 2rem; }
.cat-nombre { font-size: .78rem; font-weight: 700; color: var(--text); line-height: 1.3; }
.cat-count  { font-size: .68rem; color: var(--muted); }

.seccion-cat { margin-bottom: 32px; }
.seccion-cat-titulo {
  display: flex; align-items: center; gap: 10px;
  font-size: 1rem; font-weight: 700;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 2px solid var(--border-light);
}

.categoria { margin-bottom: 28px; }
.categoria-titulo {
  font-size: .72rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 2px solid var(--border-light);
  display: flex; align-items: center; gap: 8px;
}

.doc-card {
  background: var(--surface); border-radius: var(--r);
  box-shadow: var(--shadow-xs); padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 10px; border: 1px solid var(--border-light);
  transition: box-shadow .2s ease, transform .2s ease;
}
.doc-card:hover { box-shadow: var(--shadow); }
.doc-card:active { transform: scale(.985); }

.doc-icono {
  width: 42px; height: 42px; background: var(--primary-light);
  border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 1.1rem; flex-shrink: 0;
}
.doc-info  { flex: 1; min-width: 0; }
.doc-titulo { font-weight: 700; font-size: .9rem; }
.doc-desc   { font-size: .82rem; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.doc-meta   { display: flex; align-items: center; gap: 8px; margin-top: 5px; flex-wrap: wrap; }
.doc-fecha  { font-size: .7rem; color: var(--muted); }
.doc-tag-familia {
  background: var(--accent-light); color: #3a7a5a;
  font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 10px;
}

.doc-actions {
  display: flex; gap: 6px; flex-shrink: 0; align-items: center;
}
.btn-ver {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg); color: var(--primary); text-decoration: none;
  padding: 8px 14px; border-radius: var(--r-sm);
  font-size: .8rem; font-weight: 600; white-space: nowrap;
  min-height: 44px; transition: background .15s, color .15s; flex-shrink: 0;
  border: 1.5px solid var(--primary);
}
.btn-ver:hover { background: var(--primary); color: #fff; text-decoration: none; }
.btn-ver svg { width: 16px; height: 16px; }
.btn-descargar {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--primary); color: #fff; text-decoration: none;
  padding: 8px 16px; border-radius: var(--r-sm);
  font-size: .8rem; font-weight: 600; white-space: nowrap;
  min-height: 44px; transition: background .15s; flex-shrink: 0;
}
.btn-descargar:hover { background: var(--primary-dark); text-decoration: none; }
.btn-descargar svg { width: 16px; height: 16px; }

@media (max-width: 480px) {
  .btn-descargar span, .btn-ver span { display: none; }
  .btn-ver { padding: 8px 10px; }
  .btn-descargar { padding: 8px 10px; }
  .doc-card { padding: 12px 14px; gap: 10px; }
}

/* ═══════════════════════════════════════════════
   PAGE: Mi plan (v2 — visual redesign)
   ═══════════════════════════════════════════════ */

/* ── Dashboard cards ─────────────────────────── */
.dash-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin-bottom: 24px; animation: fadeInUp .4s ease;
}
.dash-card {
  background: var(--surface); border-radius: var(--r-lg);
  padding: 18px 16px; display: flex; align-items: flex-start; gap: 14px;
  box-shadow: var(--shadow); border: 1px solid var(--border-light);
  transition: transform .15s, box-shadow .15s;
  overflow: hidden; position: relative;
}
.dash-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.dash-card__icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.dash-card__icon svg { width: 22px; height: 22px; }
.dash-card--exam .dash-card__icon { background: #fdf0ef; color: #C0392B; }
.dash-card--work .dash-card__icon { background: #f3edf7; color: #8e44ad; }
.dash-card--study .dash-card__icon { background: #e8f4ed; color: #3A9E6E; }
.dash-card__body { flex: 1; min-width: 0; }
.dash-card__num {
  font-size: 1.8rem; font-weight: 900; line-height: 1;
  letter-spacing: -.03em; color: var(--text);
}
.dash-card__num small { font-size: .9rem; font-weight: 700; }
.dash-card__label {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); margin-top: 2px;
}
.dash-card__detail {
  font-size: .82rem; color: var(--text-sec); margin-top: 8px;
  line-height: 1.4; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.dash-card__detail--ok { color: var(--success); }
.dash-countdown {
  display: inline-block; padding: 3px 8px; border-radius: var(--r-pill);
  font-size: .72rem; font-weight: 700; background: var(--primary-light);
  color: var(--primary);
}
.dash-countdown--urgent { background: #fdf0ef; color: #C0392B; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.7; } }
.dash-card__bar {
  height: 5px; background: var(--border-light); border-radius: 4px;
  margin-top: 8px; overflow: hidden;
}
.dash-card__bar-fill {
  height: 100%; border-radius: 4px; background: linear-gradient(90deg, #3A9E6E, #27ae60);
  transition: width .6s ease;
}

/* ── Asignaturas v2 ──────────────────────────── */
.asig-section-v2 { margin-bottom: 24px; }
.asig-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.asig-add-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform .15s, background .15s;
  box-shadow: var(--shadow);
}
.asig-add-btn:hover { background: var(--primary-dark); transform: scale(1.1); }
.asig-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.asig-chip-v2 {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; background: var(--surface);
  border: 2px solid color-mix(in srgb, var(--chip-color) 30%, transparent);
  border-radius: var(--r-pill); font-size: .82rem; font-weight: 600;
  color: var(--text); box-shadow: var(--shadow-xs);
  transition: all .15s; position: relative;
}
.asig-chip-v2:hover { border-color: var(--chip-color); box-shadow: var(--shadow); }
.asig-chip__icon {
  width: 24px; height: 24px; border-radius: 50%;
  background: color-mix(in srgb, var(--chip-color) 15%, transparent);
  color: var(--chip-color);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.asig-chip__name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asig-chip__countdown {
  font-size: .65rem; font-weight: 700; padding: 1px 7px;
  border-radius: var(--r-pill); background: var(--primary-light); color: var(--primary);
}
.asig-chip__countdown.urgent { background: #fdf0ef; color: #C0392B; }
.asig-chip__del { display: inline; }
.asig-chip__del button {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: .85rem; padding: 0 2px; transition: color .12s; line-height: 1;
}
.asig-chip__del button:hover { color: var(--danger); }

/* ── Modal / Bottom sheet ────────────────────── */
.plan-modal {
  display: none; position: fixed; inset: 0; z-index: 1000;
}
.plan-modal.open { display: flex; align-items: flex-end; justify-content: center; }
.plan-modal__backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,.4);
  animation: fadeIn .2s ease;
}
.plan-modal__sheet {
  position: relative; background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 8px 24px 32px; width: 100%; max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .3s ease;
  max-height: 90vh; overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.plan-modal__handle {
  width: 36px; height: 5px; background: var(--border);
  border-radius: 3px; margin: 0 auto 12px;
  cursor: grab;
}
.plan-modal__title {
  font-size: 1.1rem; font-weight: 800; margin-bottom: 16px;
  color: var(--text); letter-spacing: -.02em;
}
.plan-modal__input {
  width: 100%; padding: 12px 16px; border: 1.5px solid var(--border);
  border-radius: var(--r-sm); font-size: .9rem; font-family: inherit;
  background: var(--bg); margin-bottom: 14px;
}
.plan-modal__input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Type selector cards */
.tipo-selector { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.tipo-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 8px; border: 2px solid var(--border); border-radius: var(--r);
  cursor: pointer; transition: all .15s; background: var(--surface);
  -webkit-tap-highlight-color: transparent;
}
.tipo-card input { display: none; }
.tipo-card span { font-size: .78rem; font-weight: 700; }
.tipo-card--repaso { color: var(--primary); }
.tipo-card--examen { color: #C0392B; }
.tipo-card--entrega { color: #8e44ad; }
.tipo-card:has(input:checked) { box-shadow: var(--shadow); transform: scale(1.03); }
.tipo-card--repaso:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }
.tipo-card--examen:has(input:checked) { border-color: #C0392B; background: #fdf0ef; }
.tipo-card--entrega:has(input:checked) { border-color: #8e44ad; background: #f3edf7; }

/* ── FAB (floating action button) ────────────── */
.plan-fab {
  position: fixed; bottom: calc(var(--bnav-h) + var(--safe-b) + 16px); right: 20px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 16px rgba(79,109,122,.35);
  transition: transform .15s, background .15s; z-index: 50;
}
.plan-fab:hover { transform: scale(1.1); background: var(--primary-dark); }
.plan-fab:active { transform: scale(.95); }

/* ── Plan onboarding ─────────────────────────── */
.plan-onboarding {
  text-align: center; padding: 40px 24px;
  animation: fadeInUp .5s ease;
}
.plan-onboarding__icon { margin-bottom: 16px; }
.plan-onboarding__title {
  font-size: 1.25rem; font-weight: 800; margin-bottom: 8px;
  letter-spacing: -.02em;
}
.plan-onboarding__sub {
  font-size: .88rem; color: var(--muted); line-height: 1.55;
  max-width: 380px; margin: 0 auto;
}
.plan-onboarding__form { margin-top: 24px; max-width: 400px; margin-left: auto; margin-right: auto; }
.plan-onboarding__input-wrap { display: flex; gap: 8px; }
.plan-onboarding__input-wrap .p-input { flex: 1; }

/* Suggested subjects grid */
.plan-sugeridas {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px;
}
.plan-sugerida-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--r-sm); font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.plan-sugerida-item:has(input:checked) {
  border-color: var(--primary); background: var(--primary-light);
}
.plan-sugerida-item input { accent-color: var(--primary); width: 18px; height: 18px; }
.plan-sugerida-item span { flex: 1; }

/* Course badge */
.plan-curso-badge {
  font-size: .65rem; font-weight: 700; letter-spacing: .06em;
  background: var(--primary); color: #fff;
  padding: 2px 10px; border-radius: var(--r-pill);
  text-transform: uppercase;
}

/* ── Week controls ───────────────────────────── */
.plan-controles {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.semana-nav { display: flex; align-items: center; gap: 8px; }
.semana-nav a {
  padding: 7px 14px; border: 1px solid var(--border); border-radius: var(--r-sm);
  text-decoration: none; color: var(--primary); font-size: .85rem; font-weight: 600;
  background: var(--surface); min-height: 36px;
  display: inline-flex; align-items: center; transition: all .15s;
}
.semana-nav a:hover { background: var(--primary-light); text-decoration: none; }
.semana-label { font-size: .9rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.vista-toggle {
  display: flex; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden;
}
.vista-toggle a {
  padding: 7px 18px; font-size: .82rem; font-weight: 600; color: var(--muted);
  text-decoration: none; background: var(--surface); transition: all .12s;
}
.vista-toggle a:hover { text-decoration: none; }
.vista-toggle a.activo { background: var(--primary); color: #fff; }

.leyenda { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.leyenda-item { display: flex; align-items: center; gap: 5px; font-size: .75rem; color: var(--muted); }
.leyenda-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ── Week grid v2 ────────────────────────────── */
.semana-grid-v2 {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px;
  margin-bottom: 16px;
}
.dia-card {
  background: var(--surface); border: 1.5px solid var(--border-light);
  border-radius: var(--r); padding: 10px 8px 12px;
  text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: all .15s; box-shadow: var(--shadow-xs);
  min-height: 120px;
}
.dia-card:hover { border-color: var(--primary); box-shadow: var(--shadow); text-decoration: none; transform: translateY(-2px); }
.dia-card--hoy {
  border-color: var(--primary); background: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.dia-card__top { text-align: center; }
.dia-card__name {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted);
}
.dia-card__num {
  font-size: 1.3rem; font-weight: 900; color: var(--text); margin-top: 2px;
}
.dia-card__ring { display: block; margin: 2px auto 0; }
.dia-card__ring-text {
  font-size: 12px; font-weight: 800; fill: var(--text);
}
.dia-card__bloques {
  width: 100%; display: flex; flex-direction: column; gap: 4px;
}
.dia-card__empty {
  font-size: .68rem; color: var(--muted); text-align: center;
  padding: 6px 0; opacity: .6;
}

/* Block pills in weekly view */
.bloque-pill {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 7px; border-radius: 6px;
  font-size: .65rem; font-weight: 600; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bloque-pill__tipo { flex-shrink: 0; display: flex; align-items: center; opacity: .85; }
.bloque-pill.pendiente { background: linear-gradient(135deg, #8A9AA4, #7A8C96); }
.bloque-pill.hecho { background: linear-gradient(135deg, #3A9E6E, #2D8A5C); }
.bloque-pill.parcial { background: linear-gradient(135deg, #E0A020, #CC8F18); }
.bloque-pill.no_hecho { background: linear-gradient(135deg, #C0392B, #A93226); }

/* ── Day view — Block cards v2 ───────────────── */
.dia-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.dia-nav a {
  padding: 7px 14px; border: 1px solid var(--border); border-radius: var(--r-sm);
  text-decoration: none; color: var(--primary); font-size: .85rem; font-weight: 600;
  background: var(--surface); min-height: 36px;
  display: inline-flex; align-items: center;
}
.dia-nav a:hover { text-decoration: none; background: var(--primary-light); }
.dia-titulo { font-size: 1rem; font-weight: 800; color: var(--text); }

.bloque-card-v2 {
  display: flex; margin-bottom: 14px; border-radius: var(--r);
  overflow: hidden; box-shadow: var(--shadow);
  background: var(--surface); border: 1px solid var(--border-light);
  transition: box-shadow .2s, transform .2s;
  animation: fadeInUp .3s ease;
}
.bloque-card-v2:hover { box-shadow: var(--shadow-md); }
.bloque-card-v2__accent {
  width: 5px; flex-shrink: 0;
  background: var(--bloque-color, var(--primary));
}
.bloque-card-v2__content {
  flex: 1; padding: 16px 18px; min-width: 0;
}
.bloque-card-v2__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.bloque-card-v2__asig {
  font-weight: 700; font-size: .95rem; color: var(--text);
  display: flex; align-items: center; gap: 7px;
}
.bloque-card-v2__tipo-icon { color: var(--bloque-color, var(--primary)); display: flex; }
.bloque-card-v2__meta {
  display: flex; align-items: center; gap: 8px;
  font-size: .78rem; color: var(--muted); margin-top: 3px;
}
.bloque-card-v2__tipo-label {
  font-size: .65rem; font-weight: 700; padding: 2px 8px;
  border-radius: var(--r-pill); text-transform: uppercase; letter-spacing: .04em;
}
.bloque-card-v2__tipo-label.tipo-examen { background: #fdf0ef; color: #C0392B; }
.bloque-card-v2__tipo-label.tipo-entrega { background: #f3edf7; color: #8e44ad; }
.bloque-card-v2__tipo-label.tipo-repaso { background: var(--primary-light); color: var(--primary); }

.bloque-card__estado {
  display: inline-block; padding: 4px 12px; border-radius: var(--r-pill);
  font-size: .72rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.bloque-card__estado.pendiente { background: linear-gradient(135deg, #8A9AA4, #7A8C96); }
.bloque-card__estado.hecho { background: linear-gradient(135deg, #3A9E6E, #2D8A5C); }
.bloque-card__estado.parcial { background: linear-gradient(135deg, #E0A020, #CC8F18); }
.bloque-card__estado.no_hecho { background: linear-gradient(135deg, #C0392B, #A93226); }

.bloque-card__tarea {
  font-size: .88rem; color: var(--text); margin: 12px 0; line-height: 1.5;
  padding: 10px 14px; background: var(--bg); border-radius: var(--r-sm);
}
.bloque-card__feedback {
  margin-top: 12px; padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent-light), #ddf0e5);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: .84rem; color: #2a6a4a; font-style: italic;
  line-height: 1.55; animation: bubbleIn .45s ease;
}

/* Mark buttons v2 */
.btn-marcar-v2 { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.btn-estado-v2 {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--r-sm); border: 2px solid var(--border);
  background: var(--surface); font-size: .82rem; font-weight: 700;
  cursor: pointer; transition: all .15s; min-height: 44px;
  font-family: inherit; flex: 1;
  justify-content: center;
}
.btn-estado-v2:hover { border-color: var(--primary); }
.btn-estado-v2--hecho:hover, .btn-estado-v2--hecho.sel { border-color: var(--hecho); background: var(--hecho); color: #fff; }
.btn-estado-v2--parcial:hover, .btn-estado-v2--parcial.sel { border-color: var(--parcial); background: var(--parcial); color: #fff; }
.btn-estado-v2--no:hover, .btn-estado-v2--no.sel { border-color: var(--no_hecho); background: var(--no_hecho); color: #fff; }
.btn-estado-v2--hecho.sel svg, .btn-estado-v2--parcial.sel svg, .btn-estado-v2--no.sel svg { stroke: #fff; }

.motivo-wrap { margin-top: 12px; display: none; }
.motivo-wrap select, .motivo-wrap textarea, .motivo-wrap input {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--r-sm); font-size: .85rem; margin-top: 8px; font-family: inherit;
  background: var(--bg);
}
.motivo-wrap select:focus, .motivo-wrap input:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.btn-confirmar {
  margin-top: 10px; padding: 10px 22px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--r-sm); font-size: .88rem; font-weight: 700;
  cursor: pointer; min-height: 44px; font-family: inherit;
}
.btn-confirmar:hover { background: var(--primary-dark); }

/* ── Form helpers (shared) ───────────────────── */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.form-row input, .form-row select {
  padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: .85rem; font-family: inherit; width: 100%; background: var(--bg);
}
.form-row input:focus, .form-row select:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.form-row label { font-size: .75rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
  .dash-grid { grid-template-columns: 1fr; gap: 10px; }
  .dash-card { padding: 16px 14px; }
}
@media (max-width: 640px) {
  .semana-grid-v2 {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  .semana-grid-v2 .dia-card:nth-child(n+6) { grid-column: span 1; }
  .form-row { grid-template-columns: 1fr; }
  .plan-controles { flex-direction: column; align-items: stretch; }
  .semana-nav { justify-content: center; }
  .vista-toggle { align-self: center; }
  .semana-label { font-size: .82rem; text-align: center; }
  .plan-onboarding { padding: 32px 16px; }
  .plan-onboarding__input-wrap { flex-direction: column; }
  .plan-sugeridas { grid-template-columns: 1fr 1fr; }
  .btn-estado-v2 { padding: 10px 10px; font-size: .78rem; }
  .bloque-card-v2__content { padding: 14px; }
  .tipo-selector { gap: 6px; }
  .tipo-card { padding: 12px 6px; }
  .tipo-card svg { width: 22px; height: 22px; }
}
@media (max-width: 420px) {
  .semana-grid-v2 { grid-template-columns: repeat(3, 1fr); }
  .dia-card { min-height: 100px; padding: 8px 6px 10px; }
  .bloque-pill { font-size: .6rem; padding: 3px 5px; }
  .dash-card__num { font-size: 1.5rem; }
  .asig-chip__name { max-width: 80px; }
}

/* Desktop: side-scroll week */
@media (min-width: 900px) {
  .semana-grid-v2 { gap: 10px; }
  .dia-card { min-height: 140px; }
}

/* ═══════════════════════════════════════════════
   PAGE: Facturas
   ═══════════════════════════════════════════════ */
.facturas-header { margin-bottom: 24px; }
.facturas-header h1 { font-size: 1.3rem; font-weight: 800; }
.facturas-header p { color: var(--muted); font-size: .9rem; margin-top: 6px; }

.factura-card {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: var(--r); padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; box-shadow: var(--shadow-xs);
  transition: box-shadow .15s;
}
.factura-card:hover { box-shadow: var(--shadow); }
.factura-card:active { transform: scale(.985); }

.factura-icon {
  width: 42px; height: 42px; background: var(--primary-light);
  border-radius: 10px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; margin-right: 14px;
}
.factura-icon svg { width: 20px; height: 20px; color: var(--primary); }

.factura-left { display: flex; align-items: center; min-width: 0; }
.factura-info { min-width: 0; }
.factura-num { font-weight: 700; font-size: .9rem; }
.factura-mes { font-size: .78rem; color: var(--muted); margin-top: 2px; }

.btn-dl {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; background: var(--primary); color: #fff;
  border-radius: var(--r-sm); font-size: .82rem; font-weight: 600;
  text-decoration: none; min-height: 44px; transition: background .15s;
  flex-shrink: 0;
}
.btn-dl:hover { background: var(--primary-dark); text-decoration: none; }
.btn-dl svg { width: 16px; height: 16px; }

@media (max-width: 480px) {
  .factura-card { padding: 14px; }
  .btn-dl span { display: none; }
}

/* ═══════════════════════════════════════════════
   PAGE: Ayuda (chat IA + contacto)
   ═══════════════════════════════════════════════ */
.ayuda-chat-card { padding: 0; overflow: hidden; }

.ayuda-chat {
  max-height: 420px; overflow-y: auto; padding: 20px 16px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
}

/* Message bubbles */
.ayuda-msg {
  display: flex; gap: 10px; align-items: flex-start;
  max-width: 88%;
}
.ayuda-msg--user {
  align-self: flex-end; flex-direction: row-reverse;
}
.ayuda-msg--ai {
  align-self: flex-start;
}
.ayuda-msg__avatar {
  width: 30px; height: 30px; flex-shrink: 0;
  background: var(--primary-light); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.ayuda-msg__avatar svg {
  width: 16px; height: 16px; color: var(--primary);
}
.ayuda-msg__bubble {
  padding: 12px 16px; border-radius: var(--r-lg);
  font-size: .88rem; line-height: 1.55;
}
.ayuda-msg--ai .ayuda-msg__bubble {
  background: var(--bg); color: var(--text);
  border-bottom-left-radius: 4px;
}
.ayuda-msg--user .ayuda-msg__bubble {
  background: var(--primary); color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.ayuda-dots { display: inline-flex; gap: 4px; align-items: center; height: 20px; }
.ayuda-dots span {
  width: 7px; height: 7px; background: var(--muted); border-radius: 50%;
  animation: ayudaDot 1.2s ease-in-out infinite;
}
.ayuda-dots span:nth-child(2) { animation-delay: .15s; }
.ayuda-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes ayudaDot {
  0%, 60%, 100% { opacity: .3; transform: scale(.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* Quick action chips */
.ayuda-chips {
  display: flex; gap: 8px; padding: 0 16px 12px;
  flex-wrap: wrap;
}
.ayuda-chip {
  padding: 8px 16px; border: 1.5px solid var(--border);
  border-radius: var(--r-pill); background: var(--surface);
  font-size: .8rem; font-weight: 600; color: var(--primary);
  cursor: pointer; font-family: inherit;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.ayuda-chip:hover {
  border-color: var(--primary); background: var(--primary-light);
}
.ayuda-chip:active { transform: scale(.95); }

/* Input bar */
.ayuda-input {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  background: var(--surface);
}
.ayuda-input__field {
  flex: 1; padding: 12px 16px; border: 1.5px solid var(--border);
  border-radius: var(--r-pill); font-size: .9rem;
  font-family: inherit; background: var(--bg);
  transition: border-color .15s;
}
.ayuda-input__field:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.ayuda-input__field::placeholder { color: var(--muted); }
.ayuda-input__btn {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.ayuda-input__btn:hover { background: var(--primary-dark); }
.ayuda-input__btn:active { transform: scale(.9); }
.ayuda-input__btn:disabled { opacity: .5; cursor: default; }
.ayuda-input__btn svg { display: block; }

/* Contact section */
.ayuda-contacto { }
.ayuda-contacto__title {
  font-size: 1.05rem; font-weight: 800; margin-bottom: 4px;
}
.ayuda-contacto__sub {
  font-size: .85rem; color: var(--muted); margin-bottom: 16px; line-height: 1.5;
}
.ayuda-contacto__textarea {
  resize: vertical; min-height: 100px; line-height: 1.55;
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .ayuda-chat { max-height: 350px; padding: 16px 12px; }
  .ayuda-msg { max-width: 92%; }
  .ayuda-chips { padding: 0 12px 10px; }
  .ayuda-input { padding: 10px 12px; }
}

/* ═══════════════════════════════════════════════
   FASES DE APRENDIZAJE (roadmap del usuario)
   ═══════════════════════════════════════════════ */
.fases-section { margin-bottom: 28px; }
.fases-section .p-section-label { margin-bottom: 12px; }

.fases-asig-group { margin-bottom: 24px; }
.fases-asig-title {
  font-size: .92rem; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
}
.fases-asig-progress {
  font-size: .72rem; font-weight: 500; color: var(--muted);
  background: var(--bg-alt); padding: 2px 10px; border-radius: 12px;
}

.fases-roadmap {
  position: relative; padding-left: 28px;
}
.fases-roadmap::before {
  content: ''; position: absolute; left: 10px; top: 8px; bottom: 8px;
  width: 3px; background: var(--border); border-radius: 3px;
}

.fase-item {
  position: relative; padding: 14px 16px; margin-bottom: 10px;
  background: var(--surface); border-radius: 12px;
  border: 1.5px solid var(--border);
  transition: transform .15s, box-shadow .15s;
}
.fase-item::before {
  content: ''; position: absolute; left: -23px; top: 18px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 3px solid var(--border); background: var(--surface);
  transition: all .2s;
}

.fase-item.activa {
  border-color: var(--primary);
  box-shadow: 0 2px 12px rgba(79,109,122,.12);
}
.fase-item.activa::before {
  border-color: var(--primary); background: var(--primary);
  box-shadow: 0 0 0 4px rgba(79,109,122,.15);
}
.fase-item.completada {
  border-color: var(--success); opacity: .88;
}
.fase-item.completada::before {
  border-color: var(--success); background: var(--success);
}
.fase-item.bloqueada {
  opacity: .55;
}

.fase-item__num {
  font-size: .65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); margin-bottom: 2px;
}
.fase-item__titulo {
  font-size: .95rem; font-weight: 700; color: var(--text); margin-bottom: 4px;
}
.fase-item__desc {
  font-size: .82rem; color: var(--text-sec); line-height: 1.5; margin-bottom: 6px;
}
.fase-item__obj {
  font-size: .8rem; color: var(--text); background: var(--bg);
  padding: 10px 12px; border-radius: 8px; line-height: 1.5; margin-bottom: 8px;
}
.fase-item__obj strong { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.fase-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: .65rem; font-weight: 700; color: #fff;
}
.fase-badge.bloqueada { background: #8A9AA4; }
.fase-badge.activa { background: var(--primary); }
.fase-badge.completada { background: var(--success); }

.fase-item__completada {
  font-size: .7rem; color: var(--muted); margin-left: 6px;
}

.fases-empty {
  text-align: center; padding: 24px 16px; color: var(--muted);
  font-size: .85rem;
}
.fases-empty svg { display: block; margin: 0 auto 10px; opacity: .4; }

/* Progress bar for subject */
.fases-progress-bar {
  height: 4px; background: var(--border-light); border-radius: 4px;
  margin-top: 6px; margin-bottom: 4px; overflow: hidden;
}
.fases-progress-bar__fill {
  height: 100%; border-radius: 4px; background: var(--success);
  transition: width .4s ease;
}

/* Active fase highlight animation */
.fase-item.activa {
  animation: faseActivePulse 2.5s ease-in-out infinite alternate;
}
@keyframes faseActivePulse {
  0% { box-shadow: 0 2px 12px rgba(79,109,122,.10); }
  100% { box-shadow: 0 2px 16px rgba(79,109,122,.20); }
}

@media (max-width: 600px) {
  .fases-roadmap { padding-left: 24px; }
  .fase-item { padding: 12px 14px; }
  .fase-item::before { left: -19px; width: 10px; height: 10px; }
  .fases-roadmap::before { left: 9px; }
}

/* ═══════════════════════════════════════════════
   MI PLAN 2.0 — Dashboard, Asignatura, Examen
   ═══════════════════════════════════════════════ */

/* ── Mini calendario exámenes ──────────────── */
.exam-calendar {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}
.exam-calendar__title {
  font-size: .82rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.exam-calendar__list {
  display: flex; flex-direction: column; gap: 8px;
}
.exam-cal-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--bg);
  border: 1px solid var(--border-light);
  transition: all .2s;
  text-decoration: none;
  color: var(--text);
}
.exam-cal-item:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.exam-cal-item__date {
  display: flex; flex-direction: column; align-items: center;
  background: var(--primary);
  color: #fff;
  border-radius: var(--r-sm);
  padding: 6px 10px;
  min-width: 48px;
  line-height: 1.1;
}
.exam-cal-item__date-day { font-size: 1.2rem; font-weight: 800; }
.exam-cal-item__date-month { font-size: .65rem; text-transform: uppercase; letter-spacing: .05em; opacity: .85; }
.exam-cal-item__info { flex: 1; min-width: 0; }
.exam-cal-item__subject {
  font-size: .78rem; font-weight: 600; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.exam-cal-item__name {
  font-size: .92rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.exam-cal-item__countdown {
  font-size: .72rem; font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--primary-light);
  color: var(--primary);
  white-space: nowrap;
}
.exam-cal-item__countdown--urgent {
  background: var(--danger-bg);
  color: var(--danger);
}
.exam-cal-item__countdown--today {
  background: var(--warning-bg);
  color: var(--warning);
}
.exam-calendar__empty {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: .88rem;
}

/* ── Tarjetas asignatura (grid visual) ──────── */
.asig-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 640px) { .asig-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 1024px) { .asig-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }

.asig-card {
  background: var(--surface);
  border: none;
  border-radius: 16px;
  padding: 0;
  overflow: hidden;
  transition: transform .2s cubic-bezier(.25,.46,.45,.94), box-shadow .2s;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.03);
}
.asig-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 28px rgba(79,109,122,.18);
  text-decoration: none;
}
.asig-card:active {
  transform: scale(.97);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  transition-duration: .08s;
}
.asig-card__top {
  padding: 16px 14px 12px;
  display: flex; align-items: center; gap: 10px;
  background: var(--asig-color, var(--primary));
  background-image: linear-gradient(135deg, var(--asig-color, var(--primary)), color-mix(in srgb, var(--asig-color, var(--primary)) 70%, #1a1a2e));
  border-bottom: none;
  position: relative;
  overflow: hidden;
}
.asig-card__top::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  pointer-events: none;
}
.asig-card__color {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.asig-card__name {
  font-size: .92rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: #fff;
}
.asig-card__course {
  font-size: .7rem; color: rgba(255,255,255,.75); font-weight: 500;
}
.asig-card__body {
  padding: 12px 14px 14px;
  display: flex; flex-direction: column; gap: 6px;
  flex: 1;
}
.asig-card__stat {
  display: flex; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--text-sec);
}
.asig-card__stat svg { flex-shrink: 0; opacity: .6; }
.asig-card__stat-val { font-weight: 700; color: var(--text); }
.asig-card__progress-bar {
  width: 100%; height: 4px;
  background: var(--border-light);
  border-radius: 2px; overflow: hidden;
  margin-top: 4px;
}
.asig-card__progress-fill {
  height: 100%; border-radius: 2px;
  background: var(--asig-color, var(--primary));
  transition: width .6s ease;
}
/* Card para añadir asignatura */
.asig-card--add {
  border: 2px dashed var(--border);
  background: transparent;
  box-shadow: none;
  display: flex; align-items: center; justify-content: center;
  min-height: 120px;
  cursor: pointer;
  transition: all .15s;
  color: var(--muted);
}
.asig-card--add:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: none;
  box-shadow: none;
}

/* ── Página asignatura (hero a sangre) ─────── */
.asig-hero {
  display: flex; align-items: center; gap: 16px;
  margin: -28px -28px 20px -28px;
  padding: 24px 28px 20px;
  background: var(--asig-color, var(--primary));
  background-image: linear-gradient(135deg, var(--asig-color, var(--primary)), color-mix(in srgb, var(--asig-color, var(--primary)) 65%, #1a1a2e));
  border-radius: 0 0 24px 24px;
  position: relative;
  overflow: hidden;
}
.asig-hero::before {
  content: '';
  position: absolute;
  top: -40px; right: -30px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.asig-hero__icon {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800; color: #fff;
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(4px);
  z-index: 1;
}
.asig-hero__info { z-index: 1; }
.asig-hero__info h1 {
  font-size: 1.3rem; font-weight: 800; line-height: 1.2; color: #fff;
}
.asig-hero__meta {
  font-size: .82rem; color: rgba(255,255,255,.75); display: flex; gap: 12px; margin-top: 2px;
}
@media (max-width: 640px) {
  .asig-hero { margin: -16px -16px 16px -16px; padding: 20px 16px 16px; border-radius: 0 0 20px 20px; }
}

/* ── Header contextual (back button) ───────── */
.p-header--context .p-header__back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(79,109,122,.1);
  border: none; color: var(--primary);
  cursor: pointer; transition: all .15s;
  flex-shrink: 0;
  text-decoration: none;
}
.p-header--context .p-header__back:hover { background: rgba(79,109,122,.15); }
.p-header__context-title {
  font-size: .95rem; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .82rem; font-weight: 600; color: var(--primary);
  margin-bottom: 12px;
}
.back-link:hover { text-decoration: none; opacity: .8; }

/* ── Page transitions ──────────────────────── */
.page-enter-forward { animation: slideInRight .25s ease-out; }
.page-enter-dashboard { animation: fadeInUp .3s ease-out; }
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── FAB Menu expandible ──────────────────── */
.fab-menu {
  position: fixed;
  bottom: calc(var(--bnav-h) + var(--safe-b) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
}
.fab-menu__trigger {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff; border: none;
  box-shadow: 0 4px 20px rgba(0,0,0,.2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform .2s cubic-bezier(.175,.885,.32,1.275), background .15s;
  position: relative; z-index: 2;
}
.fab-menu__trigger:active { transform: translateX(0) scale(.92); }
.fab-menu.open .fab-menu__trigger {
  transform: rotate(45deg);
  background: var(--text);
}
.fab-menu__options {
  position: absolute;
  bottom: 68px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  display: flex; flex-direction: column; gap: 10px;
  opacity: 0; pointer-events: none;
  transition: all .25s cubic-bezier(.175,.885,.32,1.275);
  align-items: center;
}
.fab-menu.open .fab-menu__options {
  opacity: 1; pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.fab-option {
  display: flex; align-items: center; gap: 10px;
  white-space: nowrap;
}
.fab-option__btn {
  width: 44px; height: 44px;
  border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,.12);
  transition: transform .15s;
  color: #fff;
}
.fab-option__btn:active { transform: scale(.9); }
.fab-option__btn--examen { background: #C0392B; }
.fab-option__btn--tarea { background: #E0A020; }
.fab-option__btn--material { background: var(--secondary); }
.fab-option__label {
  font-size: .8rem; font-weight: 600;
  background: var(--text); color: #fff;
  padding: 6px 12px; border-radius: var(--r-sm);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.fab-menu__backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 89;
}

/* ── Bottom nav spacer for FAB ─────────────── */
.p-bnav__spacer { width: 56px; pointer-events: none; }

/* ═══════════════════════════════════════════════
   SECCIONES DIFERENCIADAS POR COLOR
   ═══════════════════════════════════════════════ */

/* ── Section headers con icono de color ────── */
.section-title__icon {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.section-header--pendiente .section-title { color: var(--sec-pendiente); }
.section-header--pendiente .section-title__icon { background: var(--sec-pendiente-bg); color: var(--sec-pendiente); }
.section-header--examenes .section-title { color: var(--sec-examenes); }
.section-header--examenes .section-title__icon { background: var(--sec-examenes-bg); color: var(--sec-examenes); }
.section-header--plan .section-title { color: var(--sec-plan); }
.section-header--plan .section-title__icon { background: var(--sec-plan-bg); color: var(--sec-plan); }
.section-header--test .section-title { color: var(--sec-test); }
.section-header--test .section-title__icon { background: var(--sec-test-bg); color: var(--sec-test); }
.section-header--material .section-title { color: var(--sec-material); }
.section-header--material .section-title__icon { background: var(--sec-material-bg); color: var(--sec-material); }

.section-count {
  font-size: .68rem; font-weight: 700;
  padding: 1px 7px; border-radius: var(--r-pill);
  margin-left: 4px;
}
.section-header--pendiente .section-count { background: var(--sec-pendiente); color: #fff; }
.section-header--examenes .section-count { background: var(--sec-examenes); color: #fff; }

/* ── Section wraps (fondo coloreado) ───────── */
.section-wrap {
  border-radius: var(--r-lg);
  padding: 12px;
  margin-bottom: 16px;
}
.section-wrap--pendiente {
  background: var(--sec-pendiente-bg);
  border: 1px solid var(--sec-pendiente-border);
}
.section-wrap--pendiente .tarea-item { background: #fff; }
.section-wrap--examenes {
  background: var(--sec-examenes-bg);
  border: 1px solid var(--sec-examenes-border);
}

/* ── Tareas con color de asignatura visible ── */
.tarea-item {
  border-left: 4px solid var(--tarea-color, var(--primary));
  position: relative;
  overflow: hidden;
}
.tarea-item::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 40px;
  background: var(--tarea-color, var(--primary));
  opacity: .06;
  pointer-events: none;
}
.tarea-item__meta {
  display: flex; align-items: center; gap: 6px; margin-top: 2px;
}
.tarea-item__asig-badge {
  font-size: .68rem; font-weight: 700;
  color: var(--tarea-color, var(--primary));
  background: color-mix(in srgb, var(--tarea-color, var(--primary)) 12%, white);
  padding: 1px 8px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.tarea-item__check {
  border-color: var(--tarea-color, var(--border));
  background: color-mix(in srgb, var(--tarea-color, var(--primary)) 8%, transparent);
}
.tarea-item__check:hover {
  background: color-mix(in srgb, var(--tarea-color, var(--primary)) 20%, transparent);
  border-color: var(--tarea-color, var(--primary));
}

/* ── Exam scroll cards con color ──────────── */
.exam-scroll-card {
  text-decoration: none; color: var(--text);
  flex-shrink: 0; width: 160px;
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  transition: transform .15s;
}
.exam-scroll-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  text-decoration: none;
}
.exam-scroll-card__header {
  background: var(--exam-color, var(--sec-examenes));
  background-image: linear-gradient(135deg, var(--exam-color, var(--sec-examenes)), color-mix(in srgb, var(--exam-color, var(--sec-examenes)) 70%, #1a1a2e));
  padding: 10px 12px; color: #fff;
  position: relative; overflow: hidden;
}
.exam-scroll-card__header::after {
  content: '';
  position: absolute;
  top: -15px; right: -15px;
  width: 50px; height: 50px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  pointer-events: none;
}
.exam-scroll-card__date { font-size: .7rem; opacity: .85; font-weight: 500; }
.exam-scroll-card__title { font-size: .85rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exam-scroll-card__body { padding: 10px 12px; background: #fff; }
.exam-scroll-card__asig { font-size: .72rem; color: var(--muted); }
.exam-scroll-card__countdown { font-size: .72rem; font-weight: 600; color: var(--text-sec); }
.exam-scroll-card__countdown--urgent { color: var(--danger); font-weight: 700; }

/* ── Calendario mensual ──────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 8px;
}
.cal-header {
  font-size: .68rem; font-weight: 700; color: var(--muted);
  text-align: center; padding: 4px 0;
  text-transform: uppercase;
}
.cal-cell {
  aspect-ratio: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: 10px;
  transition: all .15s;
  text-decoration: none;
  color: var(--text);
  position: relative;
  gap: 2px;
}
.cal-cell--empty { pointer-events: none; }
.cal-cell__num {
  font-size: .82rem; font-weight: 500;
  line-height: 1;
}
.cal-cell--hoy {
  background: var(--sec-plan-bg);
  font-weight: 700;
}
.cal-cell--hoy .cal-cell__num {
  color: var(--sec-plan);
  font-weight: 800;
}
.cal-cell--sel {
  background: var(--primary);
  color: #fff;
}
.cal-cell--sel .cal-cell__num { color: #fff; font-weight: 800; }
.cal-cell--tiene:hover {
  background: var(--bg-alt);
}
.cal-cell__dots {
  display: flex; gap: 2px;
  position: absolute;
  bottom: 3px;
}
.cal-cell__dot {
  width: 5px; height: 5px;
  border-radius: 50%;
}
.cal-cell--sel .cal-cell__dot { opacity: .7; }

/* Evento en detalle día */
.cal-evento {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--ev-color, var(--primary));
  border-radius: var(--r-sm);
  color: var(--text);
  transition: all .15s;
}
.cal-evento:hover {
  border-color: var(--ev-color, var(--primary));
  box-shadow: var(--shadow-xs);
  text-decoration: none;
}
.cal-evento__icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cal-evento__info { flex: 1; min-width: 0; }
.cal-evento__titulo {
  font-size: .88rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-evento__asig {
  font-size: .72rem; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.cal-evento__tipo {
  font-size: .62rem; font-weight: 700;
  padding: 1px 6px; border-radius: var(--r-pill);
  background: var(--bg-alt); color: var(--text-sec);
}

/* ── Plan semanal visual ──────────────────── */
.plan-dia-card {
  display: flex; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r);
  padding: 10px 12px;
  transition: all .15s;
}
.plan-dia-card--hoy {
  border-color: var(--sec-plan);
  background: var(--sec-plan-bg);
  box-shadow: 0 2px 8px rgba(52,152,219,.1);
}
.plan-dia-card__fecha {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-width: 44px; flex-shrink: 0;
}
.plan-dia-card__num {
  font-size: 1.3rem; font-weight: 800; line-height: 1;
  color: var(--text);
}
.plan-dia-card--hoy .plan-dia-card__num { color: var(--sec-plan); }
.plan-dia-card__nombre {
  font-size: .65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted);
}
.plan-dia-card__hoy {
  font-size: .58rem; font-weight: 700;
  color: #fff; background: var(--sec-plan);
  padding: 1px 6px; border-radius: var(--r-pill);
  margin-top: 2px;
}
.plan-dia-card__actividades {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.plan-dia-card__item {
  display: flex; align-items: center; gap: 6px;
  font-size: .82rem; padding: 4px 8px;
  border-radius: var(--r-sm);
  flex-wrap: wrap;
}
.plan-dia-card__item--estudio {
  background: var(--sec-examenes-bg);
  border-left: 3px solid var(--sec-examenes);
}
.plan-dia-card__item--tarea {
  background: var(--sec-pendiente-bg);
  border-left: 3px solid var(--sec-pendiente);
}
.plan-dia-card__item--urgente {
  border-left-width: 4px;
}
.plan-dia-card__item--urgente .plan-dia-card__texto { font-weight: 700; }
.plan-dia-card__asig {
  font-size: .68rem; font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.plan-dia-card__texto {
  font-size: .82rem; font-weight: 500;
  color: var(--text);
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.plan-dia-card__limite {
  font-size: .65rem; font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  background: var(--bg-alt);
  padding: 1px 6px;
  border-radius: var(--r-pill);
}
.plan-dia-card__item--urgente .plan-dia-card__limite {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ── Tabs (pestañas) ──────────────────────── */
.plan-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 16px;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.plan-tab {
  padding: 10px 18px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all .15s;
  display: flex; align-items: center; gap: 6px;
}
.plan-tab:hover { color: var(--primary); text-decoration: none; }
.plan-tab.activo {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.plan-tab__count {
  background: var(--bg-alt);
  color: var(--muted);
  font-size: .7rem;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  font-weight: 700;
}
.plan-tab.activo .plan-tab__count {
  background: var(--primary-light);
  color: var(--primary);
}

/* ── Lista tareas ──────────────────────────── */
.tarea-list { display: flex; flex-direction: column; gap: 8px; }
.tarea-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  transition: all .15s;
}
.tarea-item:hover { border-color: var(--border); box-shadow: var(--shadow-xs); }
.tarea-item__check {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  background: transparent;
  padding: 0;
}
.tarea-item__check:hover { border-color: var(--primary); }
.tarea-item--entregada .tarea-item__check {
  background: var(--success);
  border-color: var(--success);
}
.tarea-item--entregada .tarea-item__check svg { stroke: #fff; }
.tarea-item--no_entregada .tarea-item__check {
  background: var(--danger);
  border-color: var(--danger);
}
.tarea-item__info { flex: 1; min-width: 0; }
.tarea-item__titulo {
  font-size: .88rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tarea-item--entregada .tarea-item__titulo {
  text-decoration: line-through; opacity: .5;
}
.tarea-item__fecha {
  font-size: .72rem; color: var(--muted);
}
.tarea-item__fecha--urgente { color: var(--danger); font-weight: 600; }
.tarea-item__fecha--hoy { color: var(--warning); font-weight: 600; }

/* ── Temario checklist ─────────────────────── */
.temario-list { display: flex; flex-direction: column; gap: 6px; }
.tema-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  transition: all .15s;
}
.tema-item:hover { border-color: var(--border); }
.tema-item__check {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
  background: transparent;
  padding: 0;
  margin-top: 1px;
}
.tema-item__check:hover { border-color: var(--success); }
.tema-item--done .tema-item__check {
  background: var(--success);
  border-color: var(--success);
}
.tema-item--done .tema-item__check svg { stroke: #fff; }
.tema-item__content { flex: 1; min-width: 0; }
.tema-item__titulo {
  font-size: .88rem; font-weight: 600;
}
.tema-item--done .tema-item__titulo {
  text-decoration: line-through; color: var(--muted);
}
.tema-item__actions {
  display: flex; gap: 6px; margin-top: 6px;
}
.tema-item__action {
  font-size: .72rem; font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-sec);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  transition: all .15s;
}
.tema-item__action:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.tema-item__materials-count {
  font-size: .7rem; color: var(--muted);
  margin-top: 4px;
}

/* ── Examen hero ───────────────────────────── */
.exam-hero {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 16px;
}
.exam-hero__date {
  display: flex; flex-direction: column; align-items: center;
  background: var(--primary);
  color: #fff;
  border-radius: var(--r);
  padding: 10px 14px;
  min-width: 60px;
  line-height: 1.1;
}
.exam-hero__date-day { font-size: 1.6rem; font-weight: 800; }
.exam-hero__date-month { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; opacity: .85; }
.exam-hero__info { flex: 1; }
.exam-hero__info h1 { font-size: 1.2rem; font-weight: 800; line-height: 1.2; }
.exam-hero__subject { font-size: .82rem; color: var(--muted); font-weight: 500; }
.exam-hero__countdown {
  font-size: .82rem; font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.exam-hero__countdown--ok { background: var(--primary-light); color: var(--primary); }
.exam-hero__countdown--warn { background: var(--warning-bg); color: var(--warning); }
.exam-hero__countdown--urgent { background: var(--danger-bg); color: var(--danger); }

/* ── Progress bar general ──────────────────── */
.progress-bar {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  border-radius: 3px;
  background: var(--success);
  transition: width .4s ease;
}

/* ── Resumen IA ────────────────────────────── */
.resumen-ia {
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--accent-light) 100%);
  border: 1px solid var(--border-light);
  border-radius: var(--r);
  padding: 16px;
  margin-top: 12px;
}
.resumen-ia__title {
  font-size: .78rem; font-weight: 700; color: var(--primary);
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
}
.resumen-ia__content {
  font-size: .85rem; color: var(--text-sec);
  line-height: 1.6;
}

/* ── Quiz card ─────────────────────────────── */
.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  transition: all .15s;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 8px;
}
.quiz-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.quiz-card__icon {
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  background: var(--accent-light);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.quiz-card__info { flex: 1; }
.quiz-card__title { font-size: .88rem; font-weight: 600; }
.quiz-card__meta { font-size: .72rem; color: var(--muted); }
.quiz-card__score {
  font-size: .82rem; font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--r-pill);
}
.quiz-card__score--good { background: var(--success-bg); color: var(--success); }
.quiz-card__score--ok { background: var(--warning-bg); color: var(--warning); }
.quiz-card__score--bad { background: var(--bg-alt); color: var(--muted); }

/* ── Upload area ───────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--r);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  background: var(--bg);
}
.upload-area:hover, .upload-area--active {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-area__icon { font-size: 2rem; margin-bottom: 8px; opacity: .5; }
.upload-area__text { font-size: .85rem; color: var(--muted); }
.upload-area__text strong { color: var(--primary); }

/* ── Sección vacía ─────────────────────────── */
.plan-empty {
  text-align: center;
  padding: 32px 20px;
  color: var(--muted);
}
.plan-empty__icon { font-size: 2.5rem; margin-bottom: 10px; opacity: .4; }
.plan-empty__text { font-size: .88rem; margin-bottom: 14px; }

/* ── FAB (floating action button) v2 ───────── */
.plan-fab-v2 {
  position: fixed;
  bottom: calc(var(--bnav-h) + var(--safe-b) + 16px);
  right: 16px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .2s;
  z-index: 50;
}
.plan-fab-v2:hover { background: var(--primary-dark); transform: scale(1.05); }
@media (min-width: 641px) {
  .plan-fab-v2 { bottom: 24px; right: 24px; }
}

/* ── Section label v2 ──────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  font-size: .82rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.section-action {
  font-size: .78rem; font-weight: 600; color: var(--primary);
  cursor: pointer;
  background: none; border: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.section-action:hover { opacity: .7; }

/* ── Responsive Mi Plan 2.0 ────────────────── */
@media (max-width: 640px) {
  .asig-grid { grid-template-columns: 1fr; }
  .exam-hero { flex-direction: column; align-items: flex-start; gap: 12px; }
  .exam-hero__date { flex-direction: row; gap: 6px; padding: 6px 12px; }
  .exam-hero__date-day { font-size: 1.1rem; }
  .plan-tabs { gap: 0; }
  .plan-tab { padding: 10px 14px; font-size: .82rem; }
  .asig-card__top { padding: 12px 14px 8px; }
  .asig-card__body { padding: 10px 14px 12px; }
}

/* ── PWA Install Banner ────────────────────── */
.pwa-install-banner {
  position: fixed;
  bottom: calc(var(--bnav-h) + var(--safe-b) + 8px);
  left: 12px; right: 12px;
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: var(--r);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  animation: fadeInUp .3s ease;
}
.pwa-install-banner__content {
  display: flex; align-items: center; gap: 10px;
  font-size: .85rem;
}
@media (min-width: 641px) {
  .pwa-install-banner {
    left: auto; right: 24px;
    bottom: 24px;
    max-width: 380px;
  }
}

/* ═══════════════════════════════════════════════
   SECCIÓN "HOY" + RACHA + GAMIFICACIÓN
   ═══════════════════════════════════════════════ */

/* ── Sección Hoy ───────────────────────────── */
.hoy-section {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.hoy-section__title {
  font-size: .82rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.hoy-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: .85rem;
  margin-bottom: 4px;
}
.hoy-item--tarea {
  background: var(--warning-bg);
  border-left: 3px solid var(--warning);
}
.hoy-item--examen {
  background: var(--danger-bg);
  border-left: 3px solid var(--danger);
}
.hoy-item--sugerencia {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
}
.hoy-item__text { flex: 1; font-weight: 500; }
.hoy-item__sub { font-size: .72rem; color: var(--muted); font-weight: 400; }
.hoy-item__badge {
  font-size: .68rem; font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  white-space: nowrap;
}

/* ── Racha bar ─────────────────────────────── */
.racha-bar {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 14px;
}
.racha-bar__info {
  font-size: .85rem; font-weight: 700;
  white-space: nowrap;
}
.racha-bar__info--active { color: var(--success); }
.racha-bar__info--inactive { color: var(--muted); }
.racha-bar__days {
  display: flex; gap: 6px; flex: 1; justify-content: flex-end;
}
.racha-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.racha-day__label {
  font-size: .6rem; color: var(--muted); font-weight: 600;
}
.racha-day__dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--border-light);
  transition: all .3s;
}
.racha-day__dot--active {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(58,158,110,.15);
}
.racha-day__dot--today {
  border: 2px solid var(--primary);
}

/* ── Progress ring SVG ─────────────────────── */
.progress-ring { transition: stroke-dashoffset .8s ease-out; }
.progress-ring-text {
  font-size: 11px; font-weight: 800;
  fill: var(--text);
}
.progress-ring-text--lg {
  font-size: 18px;
}

/* ── Asig progress card (asignatura.php) ───── */
.asig-progress-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 20px;
  box-shadow: var(--shadow);
}
.asig-progress-card__ring { flex-shrink: 0; }
.asig-progress-card__stats {
  flex: 1;
  display: flex; flex-direction: column; gap: 8px;
}
.asig-stat-row {
  display: flex; align-items: center; gap: 10px;
}
.asig-stat-row__label {
  font-size: .78rem; color: var(--muted); font-weight: 600;
  min-width: 70px;
}
.asig-stat-row__bar {
  flex: 1; height: 4px;
  background: var(--border-light);
  border-radius: 2px; overflow: hidden;
}
.asig-stat-row__bar-fill {
  height: 100%; border-radius: 2px;
  transition: width .6s ease;
}
.asig-stat-row__val {
  font-size: .78rem; font-weight: 800;
  min-width: 36px; text-align: right;
}
.motivational-text {
  font-size: .82rem; color: var(--muted);
  font-style: italic; margin-top: 4px;
}

/* ── Tema accordion ────────────────────────── */
.tema-item--expandable { cursor: pointer; flex-wrap: wrap; }
.tema-item__expand-icon {
  transition: transform .2s;
  margin-left: auto; flex-shrink: 0;
}
.tema-item--open .tema-item__expand-icon { transform: rotate(180deg); }
.tema-item__gallery {
  width: 100%;
  max-height: 0; overflow: hidden;
  transition: max-height .3s ease, padding .3s ease;
  padding: 0 0 0 34px;
}
.tema-item--open .tema-item__gallery {
  max-height: 500px;
  padding: 10px 0 4px 34px;
}
.tema-gallery-grid {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px;
}
.tema-gallery-item {
  width: 52px; height: 52px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-light);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  font-size: .65rem; font-weight: 600; color: var(--muted);
  text-decoration: none;
}
.tema-gallery-item img {
  width: 100%; height: 100%; object-fit: cover;
}

/* ── Badge row (logros) ────────────────────── */
.badge-row {
  display: flex; gap: 10px;
  overflow-x: auto;
  padding: 4px 0 8px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.badge-row::-webkit-scrollbar { display: none; }
.badge-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex-shrink: 0;
}
.badge-item__circle {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.badge-item__circle--locked {
  background: var(--border-light);
  opacity: .4;
}
.badge-item__circle--unlocked {
  background: var(--primary-light);
  border: 2px solid var(--primary);
}
.badge-item__label {
  font-size: .6rem; font-weight: 600; color: var(--muted);
  text-align: center; max-width: 56px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge-item--unlocked .badge-item__label { color: var(--primary); font-weight: 700; }

/* ── Toast notification ────────────────────── */
.toast-logro {
  position: fixed;
  bottom: calc(var(--bnav-h) + var(--safe-b) + 20px);
  left: 50%; transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  font-size: .85rem; font-weight: 600;
  z-index: 200;
  opacity: 0;
  transition: all .4s cubic-bezier(.175,.885,.32,1.275);
  pointer-events: none;
}
.toast-logro.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.toast-logro__icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* ── Mensaje psicólogo ─────────────────────── */
.msg-psicologo {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-left: 4px solid var(--primary);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 12px;
  position: relative;
}
.msg-psicologo__from {
  font-size: .72rem; font-weight: 700; color: var(--primary);
  margin-bottom: 4px;
}
.msg-psicologo__text {
  font-size: .88rem; color: var(--text);
  line-height: 1.5;
}
.msg-psicologo__close {
  position: absolute; top: 4px; right: 4px;
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 1.1rem;
  padding: 10px;
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
}

/* ── Confetti ──────────────────────────────── */
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
.confetti-particle {
  position: fixed;
  top: -10px;
  width: 8px; height: 8px;
  border-radius: 2px;
  z-index: 300;
  pointer-events: none;
  animation: confettiFall 2.5s ease-in forwards;
}

/* ── Responsive extras ─────────────────────── */
@media (max-width: 640px) {
  .asig-progress-card { flex-direction: column; align-items: stretch; gap: 14px; }
  .asig-progress-card__ring { align-self: center; }
  .racha-bar { flex-direction: column; gap: 8px; align-items: flex-start; }
  .racha-bar__days { width: 100%; justify-content: space-between; }
  .hoy-section { padding: 12px; }
  .badge-row { padding: 4px 0; }
}

/* ═══════════════════════════════════════════════
   MODO OSCURO
   ═══════════════════════════════════════════════ */
/* @media (prefers-color-scheme: dark) {
  :root {
    --bg: #121416;
    --bg-alt: #1a1d21;
    --surface: #1e2225;
    --text: #e4e6ea;
    --text-sec: #a0a4ab;
    --muted: #7a7f88;
    --border: #333840;
    --border-light: #2a2f35;
    --primary-light: rgba(79,109,122,.25);
    --primary-glow: rgba(79,109,122,.3);
    --accent-light: rgba(107,158,143,.2);
    --success-bg: rgba(58,158,110,.15);
    --warning-bg: rgba(224,160,32,.15);
    --danger-bg: rgba(192,57,43,.15);
    --sec-pendiente-bg: rgba(230,126,34,.12);
    --sec-pendiente-border: rgba(230,126,34,.25);
    --sec-examenes-bg: rgba(231,76,60,.12);
    --sec-examenes-border: rgba(231,76,60,.25);
    --sec-plan-bg: rgba(52,152,219,.12);
    --sec-plan-border: rgba(52,152,219,.25);
    --sec-test-bg: rgba(142,68,173,.12);
    --sec-material-bg: rgba(39,174,96,.12);
    --shadow-xs: 0 1px 3px rgba(0,0,0,.3);
    --shadow: 0 2px 12px rgba(0,0,0,.4);
    --shadow-md: 0 4px 24px rgba(0,0,0,.5);
    --shadow-hover: 0 6px 24px rgba(0,0,0,.5);
    --shadow-lg: 0 8px 40px rgba(0,0,0,.6);
  }
  body { background: var(--bg); }
  .p-header { background: var(--surface); border-color: var(--border); }
  .p-sidebar { background: var(--surface); border-color: var(--border); }
  .p-bnav { background: var(--surface); border-color: var(--border); }
  .plan-modal__sheet { background: var(--surface); }
  .plan-modal__backdrop { background: rgba(0,0,0,.6); }
  .asig-card__body { background: var(--surface); }
  .exam-scroll-card__body { background: var(--surface); }
  .tarea-item { background: var(--surface); border-color: var(--border); }
  .tema-item { background: var(--surface); border-color: var(--border); }
  .section-wrap--pendiente .tarea-item { background: var(--bg-alt); }
  .quiz-card { background: var(--surface); border-color: var(--border); }
  .hoy-section { background: var(--surface); border-color: var(--border); }
  .exam-calendar { background: var(--surface); border-color: var(--border); }
  .racha-bar { background: var(--surface); border-color: var(--border); }
  .msg-psicologo { background: rgba(79,109,122,.15); border-color: var(--primary); }
  .upload-area { background: var(--bg-alt); border-color: var(--border); }
  .toast-logro { background: var(--surface); }
  .fab-menu__trigger { box-shadow: 0 4px 20px rgba(0,0,0,.5); }
  .pwa-install-banner { background: var(--surface); border-color: var(--primary); }
  .tarea-item__asig-badge { background: color-mix(in srgb, var(--tarea-color, var(--primary)) 20%, var(--bg-alt)); }
  .p-input, select { background: var(--bg-alt); color: var(--text); border-color: var(--border); }
  .plan-modal__input { background: var(--bg-alt); color: var(--text); border-color: var(--border); }
  img { opacity: .9; }
} */

/* ── Dark mode toggle button ─────────────────── */
.p-header__theme-toggle {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-sec);
    display: flex;
    align-items: center;
    border-radius: 50%;
    transition: background .2s;
    -webkit-tap-highlight-color: transparent;
}
.p-header__theme-toggle:hover {
    background: var(--primary-light);
}

/* ── Custom scrollbar (desktop) ── */
@media (min-width: 641px) {
    ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    ::-webkit-scrollbar-track {
        background: var(--bg);
    }
    ::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 4px;
    }
    ::-webkit-scrollbar-thumb:hover {
        background: var(--primary);
    }
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--border) var(--bg);
    }
}

/* ═══════════════════════════════════════════════
   MODO OSCURO — CLASS TOGGLE (manual)
   ═══════════════════════════════════════════════ */
body.dark-mode {
  --bg: #121416;
  --bg-alt: #1a1d21;
  --surface: #1e2225;
  --text: #e4e6ea;
  --text-sec: #a0a4ab;
  --muted: #7a7f88;
  --border: #333840;
  --border-light: #2a2f35;
  --primary-light: rgba(79,109,122,.25);
  --primary-glow: rgba(79,109,122,.3);
  --accent-light: rgba(107,158,143,.2);
  --success-bg: rgba(58,158,110,.15);
  --warning-bg: rgba(224,160,32,.15);
  --danger-bg: rgba(192,57,43,.15);
  --sec-pendiente-bg: rgba(230,126,34,.12);
  --sec-pendiente-border: rgba(230,126,34,.25);
  --sec-examenes-bg: rgba(231,76,60,.12);
  --sec-examenes-border: rgba(231,76,60,.25);
  --sec-plan-bg: rgba(52,152,219,.12);
  --sec-plan-border: rgba(52,152,219,.25);
  --sec-test-bg: rgba(142,68,173,.12);
  --sec-material-bg: rgba(39,174,96,.12);
  --shadow-xs: 0 1px 3px rgba(0,0,0,.3);
  --shadow: 0 2px 12px rgba(0,0,0,.4);
  --shadow-md: 0 4px 24px rgba(0,0,0,.5);
  --shadow-hover: 0 6px 24px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.6);
  background: var(--bg);
}
body.dark-mode .p-header { background: var(--surface); border-color: var(--border); }
body.dark-mode .p-sidebar { background: var(--surface); border-color: var(--border); }
body.dark-mode .p-bnav { background: var(--surface); border-color: var(--border); }
body.dark-mode .plan-modal__sheet { background: var(--surface); }
body.dark-mode .plan-modal__backdrop { background: rgba(0,0,0,.6); }
body.dark-mode .asig-card__body { background: var(--surface); }
body.dark-mode .exam-scroll-card__body { background: var(--surface); }
body.dark-mode .tarea-item { background: var(--surface); border-color: var(--border); }
body.dark-mode .tema-item { background: var(--surface); border-color: var(--border); }
body.dark-mode .section-wrap--pendiente .tarea-item { background: var(--bg-alt); }
body.dark-mode .quiz-card { background: var(--surface); border-color: var(--border); }
body.dark-mode .hoy-section { background: var(--surface); border-color: var(--border); }
body.dark-mode .exam-calendar { background: var(--surface); border-color: var(--border); }
body.dark-mode .racha-bar { background: var(--surface); border-color: var(--border); }
body.dark-mode .msg-psicologo { background: rgba(79,109,122,.15); border-color: var(--primary); }
body.dark-mode .upload-area { background: var(--bg-alt); border-color: var(--border); }
body.dark-mode .toast-logro { background: var(--surface); }
body.dark-mode .fab-menu__trigger { box-shadow: 0 4px 20px rgba(0,0,0,.5); }
body.dark-mode .pwa-install-banner { background: var(--surface); border-color: var(--primary); }
body.dark-mode .tarea-item__asig-badge { background: color-mix(in srgb, var(--tarea-color, var(--primary)) 20%, var(--bg-alt)); }
body.dark-mode .p-input, body.dark-mode select { background: var(--bg-alt); color: var(--text); border-color: var(--border); }
body.dark-mode .plan-modal__input { background: var(--bg-alt); color: var(--text); border-color: var(--border); }
body.dark-mode img { opacity: .9; }
body.dark-mode .legal-modal__sheet { background: var(--surface); }

/* ═══════════════════════════════════════════════
   PRINT STYLESHEET
   ═══════════════════════════════════════════════ */
@media print {
  .p-header, .p-sidebar, .p-bnav, .p-overlay, .p-burger,
  .btn-descargar, .btn-dl, .btn-marcar, .btn-marcar-v2, .motivo-wrap,
  .plan-fab, .plan-modal, .asig-add-btn, .asig-chip__del,
  .add-form, .add-bloque-form, details > summary { display: none !important; }
  .p-content { margin-left: 0 !important; padding: 0 !important; }
  .p-wrap { padding-top: 0 !important; }
  body { background: #fff; }
}

/* ═══════════════════════════════════════════════
   FASE 2 — MOBILE POLISH (auditoría 2026-03-17)
   ═══════════════════════════════════════════════ */

/* Scroll horizontal: indicadores degradado */
.scroll-fade-wrap {
  position: relative;
}
.scroll-fade-wrap::after {
  content: '';
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 32px; pointer-events: none;
  background: linear-gradient(to right, transparent, var(--bg));
  border-radius: 0 var(--r) var(--r) 0;
  opacity: 1; transition: opacity .3s;
}
.scroll-fade-wrap.scrolled-end::after { opacity: 0; }

/* Toast global de confirmación */
.toast-global {
  position: fixed; bottom: calc(var(--bnav-h) + var(--safe-b) + 20px);
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff;
  padding: 10px 20px; border-radius: var(--r-pill);
  font-size: .82rem; font-weight: 600;
  z-index: 200; opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
.toast-global.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* ── Loading spinner overlay ── */
.p-loading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .78rem;
    color: var(--muted);
}
.p-loading::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Button loading state ── */
.p-btn--loading {
    pointer-events: none;
    opacity: .7;
}
.p-btn--loading::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    margin-left: 6px;
    display: inline-block;
    vertical-align: middle;
}

/* ── Required field indicator ── */
.p-label--required::after {
    content: ' *';
    color: var(--danger);
    font-weight: 400;
}

/* ── Form hint ── */
.p-form-hint {
    font-size: .72rem;
    color: var(--muted);
    margin-top: 4px;
}

/* ── Breadcrumb (contextual pages) ── */
.p-breadcrumb {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: .75rem;
    color: var(--muted);
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.p-breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}
.p-breadcrumb a:hover {
    text-decoration: underline;
}
.p-breadcrumb__sep {
    color: var(--border);
    font-size: .65rem;
}

/* Pantallas 320px: stack vertical notificaciones */
@media (max-width: 360px) {
  .dash-stats { gap: 6px; }
  .dash-card { min-width: 120px; }
}

/* ── Skeleton loading ── */
.p-skeleton {
    animation: skeletonPulse 1.5s ease-in-out infinite;
}
.p-skeleton__bar {
    background: var(--border-light, #EEF1F3);
    border-radius: 6px;
    animation: skeletonPulse 1.5s ease-in-out infinite;
}
.p-skeleton__card {
    background: var(--surface);
    border-radius: var(--r);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
@keyframes skeletonPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}
.p-skeleton--hidden { display: none; }
