/* Estudio — estilo para alumnos de 4.º ESO y 2.º Bach: limpio, oscuro por defecto si el móvil
   lo está, acento violeta, botones grandes. Mantiene todos los nombres de clase de app.js. */
:root {
  --fondo: #f3f4f8;
  --fondo-2: #e9ebf3;
  --tarjeta: #ffffff;
  --texto: #111827;
  --texto-suave: #6b7280;
  --borde: #e5e7ee;
  --primario: #6d28d9;
  --primario-2: #4f46e5;
  --primario-suave: #ede9fe;
  --primario-texto: #5b21b6;
  --ok: #047857;
  --ok-suave: #d1fae5;
  --aviso: #b45309;
  --aviso-suave: #fef3c7;
  --rojo: #b91c1c;
  --rojo-suave: #fee2e2;
  --radio: 18px;
  --radio-peq: 12px;
  --sombra: 0 1px 2px rgba(17, 24, 39, 0.04), 0 8px 24px -12px rgba(17, 24, 39, 0.18);
  --degradado: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  --barra-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0b0f1a;
    --fondo-2: #121829;
    --tarjeta: #151b2c;
    --texto: #eef0f6;
    --texto-suave: #98a2b8;
    --borde: #262e42;
    --primario: #a78bfa;
    --primario-2: #818cf8;
    --primario-suave: #2a2250;
    --primario-texto: #c4b5fd;
    --ok: #34d399;
    --ok-suave: #0f2f25;
    --aviso: #fbbf24;
    --aviso-suave: #3a2a08;
    --rojo: #f87171;
    --rojo-suave: #3d1515;
    --sombra: none;
    --degradado: linear-gradient(135deg, #7c3aed 0%, #4338ca 100%);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  background: var(--fondo);
  color: var(--texto);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--primario-suave); }

/* ---------- cabecera ---------- */
.cabecera {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--fondo) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
}
.cabecera .titulo { font-weight: 800; letter-spacing: -0.3px; font-size: 17px; }
.perfil-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--tarjeta); color: var(--texto); border: 1px solid var(--borde);
  border-radius: 999px; padding: 4px 12px 4px 4px; font-weight: 700; font-size: 14px; cursor: pointer;
  box-shadow: var(--sombra);
}
.perfil-btn .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--degradado); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
}
.estado { width: 10px; height: 10px; border-radius: 50%; background: var(--texto-suave); font-size: 0; }
.estado.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-suave); }
.estado.mal { background: var(--rojo); box-shadow: 0 0 0 4px var(--rojo-suave); }

/* ---------- vista y barra ---------- */
.vista { flex: 1; padding: 8px 16px calc(var(--barra-h) + 20px + env(safe-area-inset-bottom)); max-width: 760px; width: 100%; margin: 0 auto; }
.barra {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-around; gap: 2px;
  height: calc(var(--barra-h) + env(safe-area-inset-bottom));
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--tarjeta) 92%, transparent);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--borde);
}
.barra button {
  flex: 1; max-width: 96px; border: 0; background: none; color: var(--texto-suave);
  padding: 4px 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: 14px; cursor: pointer; transition: color 0.15s, background 0.15s;
}
.barra button svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.barra button span { font-size: 11px; font-weight: 700; letter-spacing: 0.1px; }
.barra button.activo { color: var(--primario-texto); background: var(--primario-suave); }
.barra button.activo svg { stroke-width: 2.3; }

/* ---------- tipografía ---------- */
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; margin: 10px 0 14px; line-height: 1.15; }
h2 { font-size: 17px; font-weight: 800; letter-spacing: -0.2px; margin: 18px 0 8px; }
h3 { font-size: 15px; font-weight: 700; margin: 14px 0 6px; }
p { line-height: 1.55; margin: 8px 0; }
a { color: var(--primario-texto); }
.suave { color: var(--texto-suave); font-size: 14px; }

/* ---------- tarjetas ---------- */
.card { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px; margin-bottom: 12px; box-shadow: var(--sombra); }
.card.click { cursor: pointer; }
.card.click:active { transform: scale(0.99); }
.card.destacada { background: var(--degradado); color: #fff; border: 0; }
.card.destacada .suave, .card.destacada h2 { color: rgba(255, 255, 255, 0.85); }
.fila { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.fila.entre { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- botones y chips ---------- */
button, .btn { font: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0;
  border-radius: var(--radio-peq); padding: 12px 18px; min-height: 44px;
  background: var(--degradado); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer;
  box-shadow: 0 6px 16px -8px rgba(99, 72, 220, 0.6); transition: transform 0.1s, filter 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.sec { background: var(--primario-suave); color: var(--primario-texto); box-shadow: none; }
.btn.peq { padding: 7px 12px; min-height: 34px; font-size: 13px; border-radius: 10px; }
.btn.ok { background: var(--ok); box-shadow: none; }
.btn.rojo { background: var(--rojo-suave); color: var(--rojo); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--primario-suave); color: var(--primario-texto); }
.chip.ok { background: var(--ok-suave); color: var(--ok); }
.chip.aviso { background: var(--aviso-suave); color: var(--aviso); }
.chip.rojo { background: var(--rojo-suave); color: var(--rojo); }
.chip.aules { background: #e0f2fe; color: #0369a1; }
.chip.wf { background: #fce7f3; color: #be185d; }
@media (prefers-color-scheme: dark) {
  .chip.aules { background: #0c2a3d; color: #7dd3fc; }
  .chip.wf { background: #3b0a24; color: #f9a8d4; }
}

/* Resumen del día (Hoy) */
.resumen-dia { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 14px; }
.resumen-dia .kpi { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: 14px; padding: 10px 8px; text-align: center; box-shadow: var(--sombra); }
.resumen-dia .kpi .n { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.1; }
.resumen-dia .kpi .l { font-size: 11px; font-weight: 700; color: var(--texto-suave); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.3px; }
.resumen-dia .kpi.rojo .n { color: var(--rojo); }
.resumen-dia .kpi.aviso .n { color: var(--aviso); }
.resumen-dia .kpi.ok .n { color: var(--ok); }
.saludo { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin: 6px 0 12px; }
.saludo h1 { margin: 0; }
.saludo .fecha { font-size: 13px; font-weight: 700; color: var(--texto-suave); text-transform: capitalize; padding-bottom: 5px; white-space: nowrap; }

/* ---------- formularios ---------- */
input, select, textarea {
  font: inherit; color: var(--texto); background: var(--fondo); border: 1px solid var(--borde);
  border-radius: var(--radio-peq); padding: 12px 14px; width: 100%; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primario); outline-offset: 0; border-color: transparent; }
input[type=file] { padding: 8px; background: none; border: 1px dashed var(--borde); font-size: 13px; }
input[type=checkbox] { min-height: 0; width: 22px; height: 22px; accent-color: var(--primario); }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
label { display: block; font-size: 13px; font-weight: 700; color: var(--texto-suave); margin: 10px 0 4px; }
label input, label select, label textarea { margin-top: 5px; font-weight: 400; color: var(--texto); }
.pestanas { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; margin-bottom: 6px; scrollbar-width: none; }
.pestanas::-webkit-scrollbar { display: none; }
.pestanas button { white-space: nowrap; border: 1px solid var(--borde); background: var(--tarjeta); color: var(--texto-suave); border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 700; cursor: pointer; }
.pestanas button.activo { background: var(--texto); border-color: var(--texto); color: var(--fondo); }

/* ---------- Pomodoro ---------- */
.pomo { text-align: center; padding: 18px 16px 16px; }
.pomo .tiempo { font-size: 64px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -2px; margin: 2px 0 6px; line-height: 1; }
.pomo .fase { font-size: 12px; color: var(--texto-suave); font-weight: 800; text-transform: uppercase; letter-spacing: 1.2px; }
.pomo.destacada .fase, .pomo.destacada .suave { color: rgba(255, 255, 255, 0.85); }
.pomo.destacada .btn { background: #fff; color: var(--primario-texto); box-shadow: none; }
.pomo.destacada .btn.sec { background: rgba(255, 255, 255, 0.18); color: #fff; }

/* ---------- Tareas ---------- */
.tarea { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--borde); }
.tarea:last-child { border-bottom: 0; }
.tarea input[type=checkbox] { margin-top: 1px; flex: none; }
.tarea .t { flex: 1; font-weight: 600; line-height: 1.35; }
.tarea.hecha .t { text-decoration: line-through; color: var(--texto-suave); font-weight: 500; }
.tarea .meta { font-size: 12px; color: var(--texto-suave); font-weight: 500; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.tarea .meta a { color: var(--primario-texto); text-decoration: none; font-weight: 700; }
.tarea .x { background: none; border: 0; color: var(--texto-suave); font-size: 20px; cursor: pointer; padding: 0 2px; line-height: 1; }

/* ---------- Tarjetas de repaso ---------- */
.flash { min-height: 240px; display: flex; flex-direction: column; justify-content: center; text-align: center; font-size: 19px; line-height: 1.5; cursor: pointer; font-weight: 600; }
.flash .lado { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--texto-suave); margin-bottom: 12px; font-weight: 800; }
.flash .resp { color: var(--primario-texto); }
.notas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.notas button { border: 0; border-radius: var(--radio-peq); padding: 14px 4px; font-weight: 800; cursor: pointer; font-size: 14px; }
.notas .n0 { background: var(--rojo-suave); color: var(--rojo); }
.notas .n1 { background: var(--aviso-suave); color: var(--aviso); }
.notas .n2 { background: var(--primario-suave); color: var(--primario-texto); }
.notas .n3 { background: var(--ok-suave); color: var(--ok); }

/* ---------- Markdown ---------- */
.md h1, .md h2, .md h3 { margin: 14px 0 6px; letter-spacing: 0; }
.md h1 { font-size: 19px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; }
.md ul, .md ol { padding-left: 22px; line-height: 1.6; }
.md p { margin: 8px 0; }
.md code { background: var(--fondo-2); padding: 1px 6px; border-radius: 6px; font-size: 0.92em; }
.md pre { background: var(--fondo-2); padding: 12px; border-radius: var(--radio-peq); overflow-x: auto; }
.md blockquote { border-left: 3px solid var(--primario); margin: 8px 0; padding: 2px 12px; color: var(--texto-suave); }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md th, .md td { border: 1px solid var(--borde); padding: 6px 8px; text-align: left; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; }
.burbuja { max-width: 90%; padding: 11px 15px; border-radius: 18px; line-height: 1.5; font-size: 15px; }
.burbuja.yo { align-self: flex-end; background: var(--degradado); color: #fff; border-bottom-right-radius: 5px; white-space: pre-wrap; }
.burbuja.tutor { align-self: flex-start; background: var(--tarjeta); border: 1px solid var(--borde); border-bottom-left-radius: 5px; }
.chat-form { position: fixed; left: 0; right: 0; bottom: calc(var(--barra-h) + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--fondo) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding: 8px 16px 10px; }
.chat-form .inner { max-width: 760px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.chat-form textarea { min-height: 46px; max-height: 140px; border-radius: 22px; padding: 12px 16px; }
.chat-form .btn { width: 46px; height: 46px; padding: 0; border-radius: 50%; flex: none; }
.con-chat { padding-bottom: calc(var(--barra-h) + 100px + env(safe-area-inset-bottom)); }

/* ---------- diálogos ---------- */
.dialogo { border: 0; border-radius: 22px; padding: 22px 20px; width: min(92vw, 420px); background: var(--tarjeta); color: var(--texto); box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.5); }
.dialogo::backdrop { background: rgba(5, 8, 20, 0.55); backdrop-filter: blur(3px); }
.dialogo h2 { margin-top: 0; font-size: 20px; }
.dialogo .acciones { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialogo button { border: 0; border-radius: var(--radio-peq); padding: 11px 16px; min-height: 44px; background: var(--degradado); color: #fff; font-weight: 700; cursor: pointer; }
.dialogo button.sec { background: var(--primario-suave); color: var(--primario-texto); }
.dialogo button.x { background: none; color: var(--texto-suave); min-height: 0; padding: 4px 8px; font-size: 18px; }
.lista-perfiles { display: flex; flex-direction: column; gap: 8px; }
.lista-perfiles .p { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 14px; cursor: pointer; font-weight: 600; }
.lista-perfiles .p.activo { border-color: var(--primario); background: var(--primario-suave); }
.perfil-aules { margin-top: 12px; padding: 10px 12px; border-radius: 14px; background: var(--fondo); font-size: 13px; line-height: 1.5; }
.perfil-aules:empty { display: none; }
.perfil-aules a { color: var(--primario-texto); font-weight: 700; cursor: pointer; }

/* Web Família (bloque de la otra sesión) */
.com { padding: 8px 0; border-bottom: 1px solid var(--borde); }
.com:last-child { border-bottom: 0; }
.com summary { font-weight: 700; cursor: pointer; }
.com .meta { font-size: 12px; color: var(--texto-suave); margin: 2px 0 4px; }
.com p { margin: 4px 0; white-space: pre-wrap; font-size: 14px; }

/* ---------- varios ---------- */
.aviso { background: var(--aviso-suave); color: var(--aviso); padding: 10px 14px; border-radius: var(--radio-peq); font-size: 14px; margin-bottom: 12px; font-weight: 600; }
.error { background: var(--rojo-suave); color: var(--rojo); padding: 10px 14px; border-radius: var(--radio-peq); font-size: 14px; margin: 8px 0; font-weight: 600; }
.cargando { color: var(--texto-suave); font-size: 14px; }
.cargando::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: puntos 1.2s steps(4) infinite; }
@keyframes puntos { to { content: "..."; } }
.archivos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
details summary { cursor: pointer; font-weight: 700; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "›"; float: right; font-size: 20px; line-height: 1; color: var(--texto-suave); transition: transform 0.15s; }
details[open] summary::after { transform: rotate(90deg); }
.paso { display: flex; gap: 12px; margin: 10px 0; align-items: flex-start; }
.paso .num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--degradado); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; }
.vacio { text-align: center; color: var(--texto-suave); padding: 18px 8px; font-size: 14px; }
.vacio .ico { font-size: 34px; margin-bottom: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
