/* ============================================================
   FocusPI — Accesibilidad lectora (dislexia / estres visual)
   Se carga DESPUES de app.css para poder sobrescribir tokens.

   Basado en las recomendaciones de la British Dyslexia Association:
   - Evitar contraste extremo (blanco puro sobre negro puro deslumbra).
   - Fondos crema/pastel; texto oscuro pero NO negro puro.
   - Interlineado >= 1.5, texto grande, espaciado generoso.
   - Linea corta (60-70 caracteres), alineado a la izquierda, sin justificar.
   - Sin cursivas para enfatizar, sin partir palabras con guiones.
   ============================================================ */

/* ---------- Variables ajustables por el usuario ---------- */
:root {
  --a11y-base: 17px;        /* tamano base (rem) */
  --a11y-line: 1.9;         /* interlineado */
  --a11y-letter: 0.8px;     /* espaciado entre letras */
  --a11y-word: 3px;         /* espaciado entre palabras */
  --a11y-measure: 62ch;     /* ancho maximo de lectura */
  --a11y-para: 0.9em;       /* separacion entre parrafos */
  --code-bg: #0b0b0b;
}

html { font-size: var(--a11y-base); }

body {
  /* 1rem para que TODO escale con --a11y-base (app.css lo fijaba en px) */
  font-size: 1rem;
  line-height: var(--a11y-line);
  letter-spacing: var(--a11y-letter);
  word-spacing: var(--a11y-word);
  text-align: left;
  hyphens: none;            /* nunca partir palabras */
}

/* Nada de justificado ni cursivas decorativas: dificultan la lectura */
p, li, td, th, .task-title, .subtask-title, .review-front, .review-back {
  text-align: left !important;
  hyphens: none;
}
.ai-content em, .ai-content i { font-style: normal; font-weight: 700; }

/* Longitud de linea comoda en los bloques de lectura larga */
.ai-content, .review-back, .audit-body, .mindmap, .task-desc {
  max-width: var(--a11y-measure);
}
.ai-content p, .ai-content li { margin-bottom: var(--a11y-para); }
.ai-content li { margin-top: .2em; }

/* ============================================================
   TEMAS DE FONDO
   Cada tema redefine los tokens de app.css.
   El acento amatista se mantiene, ajustando su tono para
   conservar el contraste en fondos claros.
   ============================================================ */

/* --- Carbon suave (oscuro por defecto, texto calido sin deslumbrar) --- */
html[data-theme="carbon"] {
  --text: #E8E6E3;
  --muted: #A2A0A6;
}

/* --- Crema (recomendado para dislexia) --- */
html[data-theme="crema"] {
  --bg: #FAF4E6;
  --bg-2: #F5EDDC;
  --surface: #FFFAF0;
  --surface-2: #F3EADA;
  --surface-3: #EBE0CC;
  --border: #E0D4BC;
  --border-soft: #EADFC9;
  --text: #3B342A;
  --muted: #6E6455;
  --muted-2: #8B8172;
  --accent: #6A4F93;
  --accent-hover: #58407C;
  --accent-press: #47336A;
  --accent-soft: rgba(106, 79, 147, 0.12);
  --accent-ring: rgba(106, 79, 147, 0.35);
  --code-bg: #F1E8D6;
  --hm-0: #EBE0CC; --hm-1: #CBBBDF; --hm-2: #A98FC9; --hm-3: #8467AE; --hm-4: #6A4F93;
  --shadow-sm: 0 1px 2px rgba(90,75,50,.10);
  --shadow: 0 4px 14px rgba(90,75,50,.12);
  --shadow-lg: 0 12px 34px rgba(90,75,50,.18);
}

/* --- Sepia (mas calido, menos brillo) --- */
html[data-theme="sepia"] {
  --bg: #F1E4CE;
  --bg-2: #EBDCC2;
  --surface: #F7EDDB;
  --surface-2: #EADCC4;
  --surface-3: #E0D0B4;
  --border: #D6C3A3;
  --border-soft: #E2D2B6;
  --text: #43372A;
  --muted: #6F6152;
  --muted-2: #8A7B69;
  --accent: #6A4F93;
  --accent-hover: #58407C;
  --accent-press: #47336A;
  --accent-soft: rgba(106, 79, 147, 0.12);
  --accent-ring: rgba(106, 79, 147, 0.35);
  --code-bg: #E8DAC0;
  --hm-0: #E0D0B4; --hm-1: #C9B7DC; --hm-2: #A78CC6; --hm-3: #8266AC; --hm-4: #674C90;
  --shadow-sm: 0 1px 2px rgba(90,70,40,.10);
  --shadow: 0 4px 14px rgba(90,70,40,.12);
  --shadow-lg: 0 12px 34px rgba(90,70,40,.18);
}

/* --- Azul niebla (claro, frio suave: reduce el estres visual) --- */
html[data-theme="azul"] {
  --bg: #E4EDF5;
  --bg-2: #DCE7F1;
  --surface: #F0F6FB;
  --surface-2: #DFE9F3;
  --surface-3: #D2DFEC;
  --border: #C3D4E4;
  --border-soft: #D6E2ED;
  --text: #2B3742;
  --muted: #5B6B79;
  --muted-2: #7A8894;
  --accent: #5F4A88;
  --accent-hover: #4E3B73;
  --accent-press: #3F2F5F;
  --accent-soft: rgba(95, 74, 136, 0.12);
  --accent-ring: rgba(95, 74, 136, 0.35);
  --code-bg: #DCE6F0;
  --hm-0: #D2DFEC; --hm-1: #C2B8DC; --hm-2: #A192C6; --hm-3: #7E6BAB; --hm-4: #5F4A88;
  --shadow-sm: 0 1px 2px rgba(40,60,80,.10);
  --shadow: 0 4px 14px rgba(40,60,80,.12);
  --shadow-lg: 0 12px 34px rgba(40,60,80,.18);
}

/* --- Menta (verde muy suave) --- */
html[data-theme="menta"] {
  --bg: #E3EFE6;
  --bg-2: #DAE9DE;
  --surface: #EFF7F1;
  --surface-2: #DEEBE2;
  --surface-3: #CEE0D4;
  --border: #C0D6C7;
  --border-soft: #D3E3D8;
  --text: #2C3A31;
  --muted: #5B6D62;
  --muted-2: #7A8A80;
  --accent: #5F4A88;
  --accent-hover: #4E3B73;
  --accent-press: #3F2F5F;
  --accent-soft: rgba(95, 74, 136, 0.12);
  --accent-ring: rgba(95, 74, 136, 0.35);
  --code-bg: #DBE9DF;
  --hm-0: #CEE0D4; --hm-1: #C0B6D8; --hm-2: #9F8FC2; --hm-3: #7C69A8; --hm-4: #5F4A88;
  --shadow-sm: 0 1px 2px rgba(40,70,50,.10);
  --shadow: 0 4px 14px rgba(40,70,50,.12);
  --shadow-lg: 0 12px 34px rgba(40,70,50,.18);
}

/* --- Grafito (oscuro pero sin negro puro: menos halo) --- */
html[data-theme="grafito"] {
  --bg: #22262B;
  --bg-2: #272C32;
  --surface: #2C323A;
  --surface-2: #333A43;
  --surface-3: #3B434D;
  --border: #414A55;
  --border-soft: #333A43;
  --text: #E4E6E9;
  --muted: #A7B0BA;
  --muted-2: #8A939D;
  --accent: #9B84C4;
  --accent-hover: #B29ED6;
  --accent-press: #7B5EA7;
  --accent-soft: rgba(155, 132, 196, 0.16);
  --accent-ring: rgba(155, 132, 196, 0.40);
  --code-bg: #1D2126;
  --hm-0: #333A43; --hm-1: #4A4166; --hm-2: #64548A; --hm-3: #8069AE; --hm-4: #9B84C4;
}

/* Bloques de codigo siguen el tema */
.code-input { background: var(--code-bg) !important; }
.code-block, .ai-content pre { background: var(--code-bg); }

/* El login tambien respeta el tema */
html[data-theme="crema"] .login-body,
html[data-theme="sepia"] .login-body,
html[data-theme="azul"] .login-body,
html[data-theme="menta"] .login-body { background: var(--bg); }
html[data-theme="grafito"] .login-body {
  background: radial-gradient(circle at 50% 0%, #2E2A3A 0%, var(--bg) 55%);
}

/* ============================================================
   Regla de lectura / foco de linea
   ============================================================ */
#reading-ruler {
  position: fixed; left: 0; right: 0; height: var(--ruler-h, 2.6em);
  pointer-events: none; z-index: 70; display: none;
}
html[data-ruler="regla"] #reading-ruler {
  display: block;
  background: var(--accent-soft);
  border-top: 2px solid var(--accent-ring);
  border-bottom: 2px solid var(--accent-ring);
}
/* Foco: oscurece todo menos la banda activa */
html[data-ruler="foco"] #reading-ruler { display: block; background: transparent; }
html[data-ruler="foco"] #ruler-top,
html[data-ruler="foco"] #ruler-bottom {
  position: fixed; left: 0; right: 0; background: rgba(0,0,0,.55);
  pointer-events: none; z-index: 69;
}
html:not([data-ruler="foco"]) #ruler-top,
html:not([data-ruler="foco"]) #ruler-bottom { display: none; }
html[data-theme="crema"][data-ruler="foco"] #ruler-top,
html[data-theme="crema"][data-ruler="foco"] #ruler-bottom,
html[data-theme="sepia"][data-ruler="foco"] #ruler-top,
html[data-theme="sepia"][data-ruler="foco"] #ruler-bottom,
html[data-theme="azul"][data-ruler="foco"] #ruler-top,
html[data-theme="azul"][data-ruler="foco"] #ruler-bottom,
html[data-theme="menta"][data-ruler="foco"] #ruler-top,
html[data-theme="menta"][data-ruler="foco"] #ruler-bottom { background: rgba(60,50,30,.28); }

/* ============================================================
   Lectura biónica (refuerza el inicio de cada palabra)
   ============================================================ */
.bionic { font-weight: 700; }

/* ============================================================
   Resaltado de párrafo al pasar el ratón
   ============================================================ */
html[data-hl="1"] .ai-content p:hover,
html[data-hl="1"] .ai-content li:hover,
html[data-hl="1"] .review-front:hover,
html[data-hl="1"] .review-back:hover {
  background: var(--accent-soft);
  border-radius: 6px;
  box-shadow: 0 0 0 6px var(--accent-soft);
}

/* ============================================================
   Reducir animaciones
   ============================================================ */
html[data-motion="0"] *,
html[data-motion="0"] *::before,
html[data-motion="0"] *::after {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   Subida de apuntes propios
   ============================================================ */
.upload-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .4rem; text-align: center; cursor: pointer;
  padding: 1.4rem 1rem; margin-bottom: .9rem;
  border: 2px dashed var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--muted);
  transition: border-color var(--trans), background var(--trans);
}
.upload-drop:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.upload-drop input[type=file] { display: none; }
.upload-ico { font-size: 1.8rem; }
.upload-list {
  list-style: none; margin: 0 0 .9rem; padding: .5rem .7rem;
  background: var(--surface-2); border-radius: var(--r-xs);
  font-size: .8rem; color: var(--muted);
}
.upload-list li { padding: .12rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Galeria de apuntes originales */
.orig-gallery {
  display: flex; gap: .6rem; flex-wrap: wrap;
  padding: .8rem; margin-bottom: .9rem;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
}
.orig-thumb { display: block; line-height: 0; }
.orig-thumb img {
  max-width: 190px; max-height: 240px; width: auto; height: auto;
  border-radius: var(--r-xs); border: 1px solid var(--border);
  transition: transform var(--trans), box-shadow var(--trans);
}
.orig-thumb:hover img { transform: scale(1.03); box-shadow: var(--shadow); }
.orig-pdf {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .6rem .8rem; border-radius: var(--r-xs);
  background: var(--surface); border: 1px solid var(--border);
  font-size: .85rem;
}
.orig-pdf:hover { border-color: var(--accent); text-decoration: none; }

/* Marcas de la transcripcion */
.ai-content mark {
  background: var(--accent-soft); color: var(--text);
  padding: 0 .25em; border-radius: 4px; font-size: .92em;
}
.ai-content table {
  border-collapse: collapse; width: 100%; margin: .7rem 0; font-size: .92em;
}
.ai-content th, .ai-content td {
  border: 1px solid var(--border); padding: .45rem .6rem; text-align: left;
}
.ai-content th { background: var(--surface-2); font-weight: 700; }
.ai-content figure { margin: .7rem 0; }
.ai-content figcaption { color: var(--muted); font-size: .85em; }

/* ============================================================
   Eficacia de estudio
   ============================================================ */

/* Consejo segun energia */
.energy-advice {
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  padding: .6rem .85rem; margin: .5rem 0; font-size: .9rem;
}

/* Siguiente paso */
.step-list { list-style: none; margin: 0 0 .8rem; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.step-item { display: flex; align-items: center; gap: .5rem; font-size: .9rem;
             background: var(--surface-2); border-radius: var(--r-xs); padding: .45rem .6rem; }
.step-text { flex: 1; }
.step-item .btn-icon { font-size: 1rem; }
.next-step-prompt {
  margin-top: .9rem; padding: .8rem; border-radius: var(--r-sm);
  background: var(--accent-soft); border: 1px solid var(--accent-ring);
}

/* Calibracion de confianza */
.conf-block { margin: .5rem 0 1rem; }
.conf-buttons { display: flex; gap: .45rem; justify-content: center; flex-wrap: wrap; margin-bottom: .6rem; }
.conf {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: .5rem .8rem; border-radius: var(--r-sm); font-weight: 700; font-size: .82rem;
  transition: all var(--trans);
}
.conf:hover, .conf.chosen { border-color: var(--accent); color: var(--accent-hover); background: var(--accent-soft); }
.small-btn { font-size: .78rem; padding: .35rem .7rem; }

.calib-label { font-weight: 700; margin: 0 0 .7rem; }
.calib-label.ok { color: var(--ok); }
.calib-label.warn { color: var(--warn); }
.calib-label.danger { color: var(--danger); }
.calib-label.info { color: var(--accent-hover); }
.calib-bars { display: flex; flex-direction: column; gap: .5rem; }
.calib-row { display: flex; align-items: center; gap: .6rem; font-size: .82rem; }
.calib-row > span:first-child { min-width: 110px; color: var(--muted); }
.calib-bar { flex: 1; height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.calib-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.calib-bar.real > span { background: var(--ok); }

/* Curva del olvido */
.forget-list { list-style: none; margin: 0 0 .8rem; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.forget-row { display: flex; align-items: center; gap: .6rem; font-size: .84rem; }
.fr-front { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-bar { width: 90px; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; flex: none; }
.fr-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--ok); }
.fr-bar.mid > span { background: var(--warn); }
.fr-bar.low > span { background: var(--danger); }
.fr-pct { min-width: 38px; text-align: right; color: var(--muted); font-size: .8rem; }

/* Distracciones */
.distract-quick {
  margin-top: .9rem; padding: .7rem; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px dashed var(--border);
}
.distract-btns { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: center; margin-top: .45rem; }
.distract-btns .btn-mini { font-size: .74rem; padding: .28rem .5rem; }
.distraction-list { list-style: none; margin: .6rem 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.distraction-row { display: flex; align-items: center; gap: .6rem; font-size: .84rem; }
.dr-name { min-width: 120px; }
.dr-bar { flex: 1; height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.dr-bar > span { display: block; height: 100%; background: var(--warn); border-radius: 999px; }
.dr-n { min-width: 24px; text-align: right; color: var(--muted); font-weight: 700; }

/* Contadores de tiempo por asignatura */
.project-time { display: flex; gap: .5rem; align-items: baseline; }
.pt-hours { font-size: 1.35rem; font-weight: 700; color: var(--accent-hover); }
.pt-days { font-size: .78rem; color: var(--muted); }
.time-tiles { display: flex; gap: .7rem; flex-wrap: wrap; margin: .9rem 0 .4rem; }
.tt {
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: var(--r-sm); padding: .7rem 1rem; text-align: center; min-width: 96px;
}
.tt-num { display: block; font-size: 1.5rem; font-weight: 700; color: var(--accent-hover); }
.tt-lb { font-size: .72rem; color: var(--muted); }

/* Dictado por voz */
.dictado-wrap { position: relative; display: block; }
.dictado-btn {
  position: absolute; right: .45rem; bottom: .45rem; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: .85rem; line-height: 1; cursor: pointer; padding: 0;
  transition: all var(--trans);
}
.dictado-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.dictado-btn.rec { background: var(--danger); border-color: var(--danger); color: #fff;
                   animation: dictpulse 1.2s ease-in-out infinite; }
@keyframes dictpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(207,122,122,.6); }
                       50% { box-shadow: 0 0 0 7px rgba(207,122,122,0); } }
.dictado-wrap textarea { padding-bottom: 2.4rem; }

/* ============================================================
   Progreso visual (barras, anillos, sparklines, celebración)

   Todo el movimiento se anula con data-motion="0" (panel 👁️) y con
   prefers-reduced-motion: la informacion NUNCA depende de la animacion.
   ============================================================ */

/* ---------- Barra de progreso semanal ---------- */
.goal-head { display: flex; align-items: baseline; gap: .35rem; margin-top: .3rem; }
.goal-done { font-size: 1.5rem; font-weight: 700; color: var(--accent-hover); font-variant-numeric: tabular-nums; }
.goal-of { font-size: .78rem; color: var(--muted); flex: 1; }
.goal-left { margin: .35rem 0 .6rem; }

.prog {
  position: relative; height: 14px; border-radius: 999px;
  background: var(--surface-2); overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.12);
}
.prog-fill {
  display: block; height: 100%; width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-press), var(--accent-hover));
  transition: width 1100ms cubic-bezier(.22,.9,.3,1);
  position: relative; overflow: hidden;
}
/* Brillo que recorre la barra: sutil, no hipnotico */
.prog-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent);
  transform: translateX(-100%);
  animation: shimmer 2.6s ease-in-out 1.1s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

.prog.low  .prog-fill { background: linear-gradient(90deg, #8a7a63, var(--warn)); }
.prog.mid  .prog-fill { background: linear-gradient(90deg, var(--accent-press), var(--accent)); }
.prog.good .prog-fill { background: linear-gradient(90deg, var(--accent), var(--accent-hover)); }
.prog.done .prog-fill { background: linear-gradient(90deg, #4f8f68, var(--ok)); }
.prog.done { box-shadow: inset 0 1px 2px rgba(0,0,0,.12), 0 0 0 2px color-mix(in srgb, var(--ok) 35%, transparent); }

.prog-pct {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: .68rem; font-weight: 700; color: var(--text);
  text-shadow: 0 1px 2px rgba(0,0,0,.25); pointer-events: none;
}

/* ---------- Sparkline de 7 días ---------- */
.spark { display: flex; align-items: flex-end; gap: 4px; height: 48px; margin: .6rem 0; }
.spark.big { height: 74px; gap: 8px; max-width: 380px; }
.spark-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.spark-bar {
  width: 100%; border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--accent-hover), var(--accent));
  height: var(--h); min-height: 3px;
  transform-origin: bottom;
  animation: growBar 620ms cubic-bezier(.22,.9,.3,1) backwards;
  animation-delay: calc(var(--i) * 55ms);
}
@keyframes growBar { from { transform: scaleY(0); opacity: .3; } to { transform: scaleY(1); opacity: 1; } }
.spark-lb { font-size: .62rem; color: var(--muted); margin-top: .25rem; }
.spark-col:hover .spark-bar { filter: brightness(1.2); }

/* ---------- Anillo de objetivo semanal ---------- */
.detail-progress { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; margin: 1rem 0 .4rem; }
.ring-stat { position: relative; width: 120px; height: 120px; flex: none; }
.goal-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.gr-track { fill: none; stroke: var(--surface-2); stroke-width: 10; }
.gr-fill {
  fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 326.7;
  animation: ringIn 1200ms cubic-bezier(.22,.9,.3,1) backwards;
}
.goal-ring.done .gr-fill { stroke: var(--ok); }
.goal-ring.low  .gr-fill { stroke: var(--warn); }
@keyframes ringIn { from { stroke-dashoffset: 326.7; } }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0;
}
.ring-pct { font-size: 1.9rem; font-weight: 700; color: var(--accent-hover); line-height: 1; font-variant-numeric: tabular-nums; }
.ring-sym { font-size: .9rem; color: var(--accent-hover); margin-top: -.4rem; }
.ring-lb { font-size: .66rem; color: var(--muted); }

/* ---------- Anillo del Pomodoro ---------- */
.pomo-ring-wrap { position: relative; width: 210px; height: 210px; margin: .8rem auto .2rem; }
.pomo-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 8; }
.ring-fill {
  fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 339.29;
  transition: stroke-dashoffset 1s linear;
}
.pomo-ring-wrap .pomo-display {
  position: absolute; inset: 0; display: grid; place-items: center;
  margin: 0; font-size: 2.9rem;
}

/* ---------- Aparición escalonada de tarjetas ---------- */
.reveal { animation: revealUp 480ms cubic-bezier(.22,.9,.3,1) backwards; animation-delay: var(--delay, 0ms); }
@keyframes revealUp { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Heatmap: aparición en cascada ---------- */
.hm-week { animation: fadeIn 400ms ease backwards; }
.heatmap-grid .hm-week:nth-child(n) { animation-delay: calc(var(--wi, 0) * 8ms); }
@keyframes fadeIn { from { opacity: 0; } }

/* ---------- Celebración al completar un pomodoro ---------- */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 95; overflow: hidden; }
.confetti {
  position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px;
  animation-name: confettiFall; animation-timing-function: cubic-bezier(.25,.6,.4,1);
  animation-fill-mode: forwards;
}
@keyframes confettiFall {
  0%   { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(102vh) rotate(560deg); }
}

/* ---------- Marcar tarea hecha: check suave ---------- */
.task-card.is-done { transition: opacity var(--trans), transform var(--trans); }
.task-check input { transition: transform var(--trans); }
.task-check input:checked { transform: scale(1.15); }

/* ---------- Sin animaciones: se anula TODO ---------- */
html[data-motion="0"] .prog-fill { transition: none; width: var(--target) !important; }
html[data-motion="0"] .prog-fill::after,
html[data-motion="0"] .spark-bar,
html[data-motion="0"] .gr-fill,
html[data-motion="0"] .reveal,
html[data-motion="0"] .hm-week { animation: none !important; }
html[data-motion="0"] .ring-fill { transition: none; }
html[data-motion="0"] .confetti-layer { display: none; }

@media (prefers-reduced-motion: reduce) {
  .prog-fill::after, .spark-bar, .gr-fill, .reveal, .hm-week { animation: none !important; }
  .confetti-layer { display: none; }
}

/* ============================================================
   Herramientas de estudio con IA
   ============================================================ */
.section-h { margin: 1.2rem 0 .7rem; font-size: 1rem; color: var(--muted); }

/* Glosario */
.glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .9rem; }
.term-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--r-sm);
  padding: .85rem .95rem;
  transition: box-shadow var(--trans), transform var(--trans);
}
.term-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.term-head { display: flex; align-items: center; gap: .4rem; margin-bottom: .3rem; }
.term-name { font-size: 1rem; color: var(--accent-hover); flex: 1; }
.term-def { font-size: .88rem; margin: 0 0 .5rem; }
.term-mnemonic {
  font-size: .85rem; margin: .4rem 0 0; padding: .5rem .65rem;
  background: var(--accent-soft); border-radius: var(--r-xs);
  border-left: 2px solid var(--accent);
}

/* Práctica: pre-test y ejemplos */
.practice-card .pc-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; flex-wrap: wrap; }
.pretest-q { margin: .9rem 0; padding-bottom: .9rem; border-bottom: 1px solid var(--border-soft); }
.pretest-q:last-child { border-bottom: none; }
.pretest-a {
  margin-top: .5rem; padding: .6rem .8rem; border-radius: var(--r-xs);
  background: var(--surface-2); border-left: 3px solid var(--ok); font-size: .88rem;
}

.ex-statement {
  padding: .8rem .95rem; border-radius: var(--r-sm);
  background: var(--surface-2); border-left: 3px solid var(--accent);
  margin-bottom: .9rem; font-size: .92rem;
}
.fade-levels { margin-bottom: .5rem; }
.ex-steps { list-style: none; counter-reset: paso; margin: .8rem 0 0; padding: 0; }
.ex-step {
  counter-increment: paso; position: relative;
  padding: .6rem 0 .8rem 2.2rem; border-bottom: 1px dashed var(--border-soft);
}
.ex-step:last-child { border-bottom: none; }
.ex-step::before {
  content: counter(paso); position: absolute; left: 0; top: .55rem;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-hover);
  display: grid; place-items: center; font-size: .78rem; font-weight: 700;
}
.es-title { font-weight: 700; display: block; margin-bottom: .25rem; }
.es-detail { font-size: .9rem; color: var(--text); animation: revealUp 320ms ease backwards; }

/* Exámenes de otros años */
.pattern-card { border-left: 3px solid var(--warn); }

html[data-motion="0"] .term-card, html[data-motion="0"] .es-detail { transition: none; animation: none !important; }

/* ============================================================
   Vista semanal del calendario
   ============================================================ */
.week-head {
  display: flex; align-items: center; gap: .9rem; flex-wrap: wrap;
  margin-bottom: .8rem;
}
.week-nav { display: flex; gap: .3rem; }
.week-label { font-size: 1rem; flex: 1; }
.week-legend { display: flex; align-items: center; gap: .4rem; font-size: .74rem; color: var(--muted); flex-wrap: wrap; }
.lg { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.lg-google { background: var(--accent); }
.lg-plan   { background: var(--ok); }
.lg-busy   { background: var(--muted-2); }

/* Franja de eventos de todo el día */
.allday-strip { display: flex; gap: .4rem; margin-bottom: .5rem; align-items: flex-start; }
.allday-lb { font-size: .68rem; color: var(--muted); width: 52px; flex: none; padding-top: .3rem; }
.allday-cols { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; flex: 1; }
.allday-col { display: flex; flex-direction: column; gap: 2px; min-height: 1.2rem; }
.ev-chip {
  font-size: .68rem; padding: .15rem .35rem; border-radius: 4px;
  background: var(--accent-soft); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ev-chip.ev-focuspi { background: color-mix(in srgb, var(--ok) 22%, transparent); }

/* Rejilla */
.week-scroll { overflow-x: auto; }
.week-grid {
  display: grid; grid-template-columns: 52px repeat(7, minmax(96px, 1fr));
  min-width: 720px;
}
.wg-hours { display: flex; flex-direction: column; }
.wg-corner { height: 38px; }
.wg-hour {
  height: 44px; font-size: .66rem; color: var(--muted);
  text-align: right; padding-right: .35rem; position: relative;
}
.wg-hour span { position: relative; top: -.45em; }

.wg-day { display: flex; flex-direction: column; border-left: 1px solid var(--border-soft); }
.wg-day.is-weekend { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.wg-dayhead {
  height: 38px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 0; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.wd-name { font-size: .66rem; color: var(--muted); text-transform: uppercase; }
.wd-num { font-size: .95rem; font-weight: 700; line-height: 1.1; }
.wg-day.is-today .wg-dayhead { background: var(--accent-soft); }
.wg-day.is-today .wd-num {
  background: var(--accent); color: #fff; border-radius: 50%;
  width: 1.5rem; height: 1.5rem; display: grid; place-items: center; font-size: .8rem;
}

.wg-slots { position: relative; flex: 1; }
.wg-slot { height: 44px; border-bottom: 1px solid var(--border-soft); }

/* Eventos posicionados */
.wg-event {
  position: absolute; left: 2px; right: 2px;
  border-radius: 5px; padding: .18rem .3rem; overflow: hidden;
  font-size: .68rem; line-height: 1.25; cursor: default;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 20%, var(--surface));
  transition: filter var(--trans), transform var(--trans);
}
.wg-event:hover { filter: brightness(1.12); transform: scale(1.015); z-index: 3; }
.wge-time { display: block; font-weight: 700; opacity: .8; }
.wge-title { display: block; overflow: hidden; text-overflow: ellipsis; }
.wge-loc { display: block; font-size: .62rem; opacity: .75; }

.wg-event.ev-google  { border-left-color: var(--accent);
                       background: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
/* Si el evento trae el color de su calendario, manda ese */
.wg-event[style*="--ev-color"] {
  border-left-color: var(--ev-color);
  background: color-mix(in srgb, var(--ev-color) 20%, var(--surface));
}

/* Leyenda de calendarios */
.cal-legend { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap;
              font-size: .74rem; color: var(--muted); margin-bottom: .6rem; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.cal-nm { margin-right: .5rem; }
.wg-event.ev-plan,
.wg-event.ev-focuspi { border-left-color: var(--ok);
                       background: color-mix(in srgb, var(--ok) 20%, var(--surface)); }
.wg-event.ev-busy    { border-left-color: var(--muted-2);
                       background: color-mix(in srgb, var(--muted-2) 18%, var(--surface));
                       opacity: .85; }
.wg-event.is-done { opacity: .5; text-decoration: line-through; }

.week-foot { margin-top: .6rem; }

@media (max-width: 700px) {
  .week-legend { width: 100%; }
  .allday-lb { width: 40px; }
}
html[data-motion="0"] .wg-event { transition: none; }
html[data-motion="0"] .wg-event:hover { transform: none; }

/* ============================================================
   Panel de accesibilidad
   ============================================================ */
.a11y-fab {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 75;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  font-size: 1.4rem; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: grid; place-items: center;
}
.a11y-fab:hover { background: var(--accent-hover); }

.a11y-panel {
  position: fixed; right: 1.1rem; bottom: 5rem; z-index: 76;
  width: min(360px, calc(100vw - 2.2rem));
  max-height: min(78vh, 640px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  padding: 1.1rem;
}
.a11y-panel h3 { margin: 0 0 .2rem; }
.a11y-group { margin-top: 1rem; }
.a11y-group > label:first-child,
.a11y-legend {
  display: block; font-size: .8rem; color: var(--muted);
  margin-bottom: .4rem; font-weight: 700;
}
.a11y-themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.a11y-theme {
  border: 2px solid var(--border); border-radius: var(--r-sm);
  padding: .5rem .3rem; cursor: pointer; text-align: center;
  font-size: .72rem; line-height: 1.25;
}
.a11y-theme.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.a11y-swatch {
  display: block; height: 24px; border-radius: 5px; margin-bottom: .3rem;
  border: 1px solid rgba(128,128,128,.35);
}
.a11y-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .55rem; }
.a11y-row label { margin: 0; flex: 1; font-size: .85rem; color: var(--text); }
.a11y-row output { font-size: .78rem; color: var(--muted); min-width: 44px; text-align: right; }
.a11y-panel input[type=range] { width: 100%; accent-color: var(--accent); }
.a11y-toggle { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; cursor: pointer; }
.a11y-toggle input { width: auto; accent-color: var(--accent); }
.a11y-toggle span { font-size: .85rem; }
.a11y-actions { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.a11y-sample {
  margin-top: .8rem; padding: .7rem; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border-soft); font-size: .88rem;
}

@media (max-width: 600px) {
  .a11y-panel { right: .6rem; left: .6rem; width: auto; bottom: 4.6rem; }
}

/* Ocultar el panel al imprimir o en modo ciego */
@media print { .a11y-fab, .a11y-panel, #reading-ruler { display: none !important; } }
