:root {
    --bg: #070b16;
    --superficie: rgba(148, 163, 184, 0.06);
    --superficie-2: rgba(148, 163, 184, 0.1);
    --borde: rgba(148, 163, 184, 0.16);
    --texto: #e6edf7;
    --texto-suave: #93a4bd;
    --cian: #22d3ee;
    --violeta: #818cf8;
    --azul: #0ea5e9;
    --verde: #34d399;
    --rojo: #fb7185;
    --grad: linear-gradient(135deg, var(--cian), var(--violeta));
    --usuario-grad: linear-gradient(135deg, var(--azul), #6366f1);
    --sombra: 0 18px 50px rgba(0, 0, 0, 0.45);
    --sombra-fuerte: 0 30px 80px rgba(0, 0, 0, 0.6);
    --radio: 18px;
    --header-bg: rgba(10, 16, 32, 0.72);
    --banner-bg: rgba(34, 211, 238, 0.12);
    --menu-bg: #0f1a30;
    --panel-bg: rgba(15, 23, 42, 0.92);
    --modal-bg: #101b33;
    --chip-bg: rgba(7, 11, 22, 0.6);
    --codigo-bg: rgba(0, 0, 0, 0.35);
    --glow-op: 0.32;
}

[data-tema="claro"] {
    --bg: #eef2f7;
    --superficie: rgba(15, 23, 42, 0.05);
    --superficie-2: rgba(15, 23, 42, 0.09);
    --borde: rgba(15, 23, 42, 0.14);
    --texto: #0f172a;
    --texto-suave: #5b6b84;
    --sombra: 0 14px 36px rgba(15, 23, 42, 0.14);
    --sombra-fuerte: 0 24px 60px rgba(15, 23, 42, 0.22);
    --header-bg: rgba(255, 255, 255, 0.85);
    --banner-bg: rgba(34, 211, 238, 0.18);
    --menu-bg: #ffffff;
    --panel-bg: rgba(255, 255, 255, 0.95);
    --modal-bg: #ffffff;
    --chip-bg: rgba(255, 255, 255, 0.7);
    --codigo-bg: rgba(15, 23, 42, 0.08);
    --glow-op: 0.18;
}

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

html, body { height: 100%; }

body {
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--texto);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background 0.25s ease, color 0.25s ease;
}

.fondos { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.glow { position: absolute; border-radius: 50%; filter: blur(95px); opacity: var(--glow-op); transition: opacity 0.25s ease; }
.g1 { width: 500px; height: 500px; background: var(--cian); top: -180px; left: -120px; }
.g2 { width: 540px; height: 540px; background: #8b5cf6; bottom: -220px; right: -140px; }
.g3 { width: 380px; height: 380px; background: var(--azul); top: 45%; left: 52%; opacity: calc(var(--glow-op) * 0.45); }

/* ===== Header ===== */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 20px;
    background: var(--header-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--borde);
    z-index: 10;
}

.logo { display: flex; align-items: center; gap: 12px; min-width: 0; cursor: pointer; }
.logo-badge {
    width: 44px; height: 44px;
    display: grid; place-items: center;
    font-size: 22px;
    border-radius: 14px;
    background: var(--grad);
    box-shadow: 0 6px 22px rgba(34, 211, 238, 0.35);
    flex-shrink: 0;
}
.logo-texto h1 {
    font-size: 19px;
    font-weight: 800;
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: -0.3px;
}
.logo-texto p { font-size: 12px; color: var(--texto-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.derecha { display: flex; align-items: center; gap: 10px; }
.stats { display: flex; gap: 8px; }
.pill {
    background: var(--superficie);
    border: 1px solid var(--borde);
    padding: 7px 13px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--texto-suave);
    display: flex; align-items: center; gap: 6px;
}
.tema-btn { font-size: 20px; padding: 8px; }

#areaUsuario { display: flex; align-items: center; gap: 8px; }
.usuario-chip {
    display: flex; align-items: center; gap: 8px;
    background: var(--superficie);
    border: 1px solid var(--borde);
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 13px; font-weight: 600;
}
.usuario-chip .avatar-mini { width: 24px; height: 24px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; font-size: 13px; }

/* ===== Banner invitado ===== */
.banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 9px 16px;
    background: var(--banner-bg);
    border-bottom: 1px solid rgba(34, 211, 238, 0.25);
    font-size: 13.5px;
    color: var(--texto);
    z-index: 9;
}

/* ===== Cuerpo + Sidebar ===== */
.cuerpo { flex: 1; display: flex; min-height: 0; width: 100%; }

.sidebar {
    width: 230px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 14px;
    background: var(--header-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--borde);
    overflow-y: auto;
}

.nav { display: flex; flex-direction: column; gap: 5px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 13px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--texto-suave);
    border-radius: 13px;
    font-size: 14.5px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: all 0.16s ease;
}
.nav-item:hover { background: var(--superficie); color: var(--texto); }
.nav-item.activo {
    background: var(--superficie-2);
    border-color: rgba(34, 211, 238, 0.35);
    color: var(--texto);
}
.nav-item.activo span { color: var(--cian); }

.sidebar-pie {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 13px;
    border-top: 1px solid var(--borde);
}
.mini-logo { width: 34px; height: 34px; display: grid; place-items: center; font-size: 17px; border-radius: 10px; background: var(--grad); }
.sidebar-pie strong { font-size: 13px; display: block; }
.sidebar-pie p { font-size: 11px; color: var(--texto-suave); }

/* ===== Main ===== */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 22px;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}

.vista {
    flex: 1;
    display: none;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 0;
    scroll-behavior: smooth;
}
.vista.activa { display: flex; }
.vista::-webkit-scrollbar { width: 9px; }
.vista::-webkit-scrollbar-track { background: transparent; }
.vista::-webkit-scrollbar-thumb { background: var(--superficie-2); border-radius: 99px; }
.vista::-webkit-scrollbar-thumb:hover { background: var(--borde); }

.encabezado-vista { margin-bottom: 16px; }
.encabezado-vista h2 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.encabezado-vista p { color: var(--texto-suave); font-size: 14px; }
.fila-entre { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fila-entre h3 { font-size: 17px; }

/* ===== Bienvenida / Inicio ===== */
.bienvenida {
    background: linear-gradient(160deg, rgba(34, 211, 238, 0.08), rgba(129, 140, 248, 0.08));
    border: 1px solid rgba(129, 140, 248, 0.28);
    border-radius: var(--radio);
    padding: 26px 24px;
    text-align: center;
    box-shadow: var(--sombra);
}
.b-emoji { font-size: 44px; margin-bottom: 6px; }
.bienvenida h2 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.bienvenida p { color: var(--texto-suave); font-size: 14.5px; line-height: 1.7; max-width: 580px; margin: 0 auto; }
.bienvenida p strong { color: var(--texto); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chip {
    background: var(--chip-bg);
    border: 1px solid var(--borde);
    color: var(--texto-suave);
    border-radius: 999px;
    padding: 9px 15px;
    font-size: 13.5px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.18s ease;
}
.chip:hover { border-color: var(--cian); color: var(--texto); transform: translateY(-1px); }

.tarjetas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.tarjeta {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 20px 18px;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}
.tarjeta:hover { border-color: rgba(34, 211, 238, 0.35); transform: translateY(-2px); }
.tarjeta-ico { font-size: 30px; margin-bottom: 10px; }
.tarjeta h3 { font-size: 15.5px; font-weight: 700; margin-bottom: 6px; }
.tarjeta p { font-size: 13.5px; color: var(--texto-suave); line-height: 1.6; }

/* ===== Chat ===== */
.conv-cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 4px 12px;
    border-bottom: 1px solid var(--borde);
    margin-bottom: 8px;
}
.conv-cabecera .conv-acciones { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.conv-cabecera .btn.activo, .icon-btn.activo { border-color: #f43f5e; color: #f43f5e; }
.conv-titulo {
    font-size: 13px;
    font-weight: 700;
    color: var(--texto-suave);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-cabecera .btn { padding: 8px 13px; font-size: 13px; border-radius: 12px; flex-shrink: 0; }

.chat {
    flex: 1;
    overflow-y: auto;
    padding: 8px 2px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: 0;
}
.chat::-webkit-scrollbar { width: 9px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb { background: var(--superficie-2); border-radius: 99px; }

.msg { display: flex; align-items: flex-start; gap: 12px; animation: aparecer 0.3s ease both; }
.msg.user { flex-direction: row-reverse; }

@keyframes aparecer {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.avatar {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    font-size: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid var(--borde);
}
.av-t { background: var(--superficie-2); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12); }
.av-u { background: rgba(99, 102, 241, 0.25); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); }

.columna { display: flex; flex-direction: column; gap: 6px; max-width: 82%; min-width: 0; }

.burbuja {
    padding: 13px 17px;
    border-radius: 18px;
    line-height: 1.6;
    font-size: 14.5px;
    word-wrap: break-word;
    box-shadow: var(--sombra);
}

.msg.teacher .burbuja {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-bottom-left-radius: 6px;
    backdrop-filter: blur(10px);
}

.msg.user .burbuja { background: var(--usuario-grad); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }

.msg.teacher .burbuja strong { color: var(--texto); font-weight: 700; }
.msg.teacher .burbuja h1, .msg.teacher .burbuja h2, .msg.teacher .burbuja h3 {
    color: var(--cian);
    margin: 12px 0 6px;
    line-height: 1.3;
}
.msg.teacher .burbuja h1 { font-size: 18px; }
.msg.teacher .burbuja h2 { font-size: 16.5px; }
.msg.teacher .burbuja h3 { font-size: 15px; }
.msg.teacher .burbuja h1:first-child, .msg.teacher .burbuja h2:first-child, .msg.teacher .burbuja h3:first-child { margin-top: 0; }
.msg.teacher .burbuja ul, .msg.teacher .burbuja ol { margin: 8px 0; padding-left: 24px; }
.msg.teacher .burbuja li { margin: 3px 0; }
.msg.teacher .burbuja ul { list-style: disc; }
.msg.teacher .burbuja ol { list-style: decimal; }
.msg.teacher .burbuja code { background: var(--codigo-bg); padding: 1px 7px; border-radius: 6px; font-size: 13px; font-family: "Cascadia Code", Consolas, monospace; }
.msg.teacher .burbuja pre { background: var(--codigo-bg); border: 1px solid var(--borde); padding: 12px; border-radius: 12px; overflow-x: auto; margin: 8px 0; }
.msg.teacher .burbuja pre code { background: none; padding: 0; }
.msg.teacher .burbuja blockquote { border-left: 3px solid var(--cian); padding: 2px 0 2px 12px; margin: 8px 0; color: var(--texto-suave); }

.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--texto-suave); padding-left: 4px; }
.meta .origen { display: inline-flex; align-items: center; gap: 5px; background: var(--superficie); border: 1px solid var(--borde); padding: 3px 10px; border-radius: 999px; }
.origen.memoria { color: var(--verde); border-color: rgba(52, 211, 153, 0.4); }
.origen.error { color: var(--rojo); border-color: rgba(251, 113, 133, 0.4); }
.meta button { background: var(--superficie); border: 1px solid var(--borde); color: var(--texto-suave); border-radius: 999px; padding: 3px 11px; font-size: 12px; font-family: inherit; cursor: pointer; transition: all 0.15s ease; }
.meta button:hover { border-color: var(--cian); color: var(--texto); }
.meta button:disabled { opacity: 0.5; cursor: default; }
.meta .btn-copiar { margin-left: auto; }

.typing { display: inline-flex; gap: 5px; align-items: center; padding: 16px 18px; }
.punto { width: 8px; height: 8px; border-radius: 50%; background: var(--cian); animation: latir 1.2s ease-in-out infinite; }
.punto:nth-child(2) { animation-delay: 0.15s; }
.punto:nth-child(3) { animation-delay: 0.3s; }
@keyframes latir {
    0%, 100% { opacity: 0.25; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.1); }
}

.hidden { display: none !important; }

/* ===== Panel enseñar ===== */
.panel {
    background: var(--panel-bg);
    border: 1px solid rgba(129, 140, 248, 0.35);
    border-radius: var(--radio);
    padding: 18px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--sombra);
    animation: aparecer 0.25s ease both;
}
.panel-cabecera { display: flex; align-items: center; justify-content: space-between; }
.panel h3 { font-size: 16px; font-weight: 700; }
.panel .sub { font-size: 13px; color: var(--texto-suave); }
.panel textarea { min-height: 110px; resize: vertical; font-family: inherit; }
.fila { display: flex; gap: 10px; }

/* ===== Selector de materia ===== */
.dropdown { position: relative; flex-shrink: 0; }
.dropdown-trigger {
    display: flex; align-items: center; gap: 8px; justify-content: space-between;
    min-width: 180px; min-height: 48px; padding: 0 14px;
    background: var(--superficie); border: 1px solid var(--borde);
    color: var(--texto); border-radius: 14px;
    font-size: 13.5px; font-family: inherit; font-weight: 600; cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.dropdown-trigger:hover, .dropdown.open .dropdown-trigger { border-color: var(--cian); background: var(--superficie-2); }
.dropdown-trigger .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--c, #22d3ee); flex-shrink: 0; }
.flecha { color: var(--texto-suave); font-size: 11px; transition: transform 0.15s ease; }
.dropdown.open .flecha { transform: rotate(180deg); }
.dropdown-menu {
    position: absolute; bottom: calc(100% + 10px); left: 0;
    width: min(320px, 84vw); max-height: 340px; overflow-y: auto;
    background: var(--menu-bg); border: 1px solid rgba(129, 140, 248, 0.35);
    border-radius: 16px; box-shadow: var(--sombra-fuerte);
    padding: 8px; z-index: 80; animation: aparecer 0.18s ease both;
}
.dropdown-menu::-webkit-scrollbar { width: 8px; }
.dropdown-menu::-webkit-scrollbar-track { background: transparent; }
.dropdown-menu::-webkit-scrollbar-thumb { background: var(--superficie-2); border-radius: 99px; }
.grupo { margin-top: 6px; }
.grupo:first-of-type { margin-top: 0; }
.grupo-titulo { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; color: var(--texto-suave); padding: 8px 10px 4px; }
.opcion {
    display: flex; align-items: center; gap: 9px; width: 100%;
    background: transparent; border: none; color: var(--texto);
    font-size: 13.5px; font-family: inherit; padding: 9px 10px; border-radius: 10px;
    cursor: pointer; text-align: left; transition: background 0.12s ease, color 0.12s ease;
}
.opcion .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, #22d3ee); flex-shrink: 0; }
.opcion:hover { background: color-mix(in srgb, var(--c, #22d3ee) 14%, transparent); color: var(--texto); }
.opcion.activa { background: color-mix(in srgb, var(--c, #22d3ee) 22%, transparent); color: var(--texto); font-weight: 700; }
.opcion.activa::after { content: "✓"; margin-left: auto; color: var(--c, #22d3ee); font-weight: 800; }

/* ===== Barra de entrada ===== */
.barra { display: flex; gap: 10px; padding: 14px 0 4px; align-items: stretch; }

.campo {
    background: var(--superficie);
    border: 1px solid var(--borde);
    color: var(--texto);
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
}
.campo::placeholder { color: var(--texto-suave); opacity: 0.7; }
.campo:focus { border-color: var(--cian); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15); }

.input-wrap {
    flex: 1;
    display: flex; align-items: center; gap: 6px;
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 16px;
    padding: 0 8px 0 16px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-wrap:focus-within { border-color: var(--cian); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15); }
.input-wrap input { flex: 1; background: transparent; border: none; outline: none; color: var(--texto); font-size: 15px; font-family: inherit; padding: 14px 0; min-width: 0; }
.input-wrap input::placeholder { color: var(--texto-suave); opacity: 0.7; }

.icon-btn { background: transparent; border: none; cursor: pointer; font-size: 16px; padding: 6px; border-radius: 10px; color: var(--texto-suave); transition: all 0.15s ease; flex-shrink: 0; }
.icon-btn:hover { background: var(--superficie-2); color: var(--texto); }
.icon-btn.grabando { color: #f43f5e; animation: parpadeo 1s infinite; }
@keyframes parpadeo { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.vista-previa {
    position: relative; flex-shrink: 0; align-self: center;
    width: 46px; height: 46px; border-radius: 12px; overflow: visible;
    border: 1px solid var(--borde);
}
.vista-previa img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 11px; }
.vista-previa .icon-btn {
    position: absolute; top: -7px; right: -7px;
    width: 18px; height: 18px; font-size: 10px; line-height: 1; padding: 0;
    background: var(--superficie-2); color: var(--texto); border-radius: 50%;
    display: grid; place-items: center;
}

.burbuja-img { display: block; margin-top: 8px; max-width: 220px; max-height: 220px; border-radius: 12px; border: 1px solid var(--borde); }

.btn {
    border: 1px solid var(--borde);
    border-radius: 14px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    color: var(--texto);
}
.btn.sm { padding: 8px 13px; font-size: 13px; border-radius: 12px; }
.btn.ghost { background: var(--superficie); color: var(--texto-suave); }
.btn.ghost:hover { background: var(--superficie-2); color: var(--texto); }
.btn.primario { background: var(--grad); border: none; color: #06121f; box-shadow: 0 6px 20px rgba(34, 211, 238, 0.3); }
.btn.primario:hover { transform: translateY(-1px); box-shadow: 0 8px 26px rgba(34, 211, 238, 0.4); }
.btn-block { width: 100%; }
.btn.enviar { background: var(--grad); border: none; color: #06121f; width: 48px; height: 48px; padding: 0; border-radius: 16px; display: grid; place-items: center; box-shadow: 0 6px 20px rgba(34, 211, 238, 0.3); flex-shrink: 0; }
.btn.enviar:hover { transform: translateY(-1px) scale(1.03); box-shadow: 0 8px 26px rgba(34, 211, 238, 0.45); }

/* ===== Listas (historial/conversaciones) ===== */
.lista-historial { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.item-conversacion {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color 0.15s ease;
}
.item-conversacion:hover { border-color: rgba(34, 211, 238, 0.35); }
.item-conversacion .ic-ico { width: 42px; height: 42px; display: grid; place-items: center; font-size: 19px; background: var(--superficie-2); border-radius: 12px; flex-shrink: 0; }
.item-conversacion .ic-info { flex: 1; min-width: 0; }
.item-conversacion .ic-titulo { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-conversacion .ic-meta { font-size: 12px; color: var(--texto-suave); margin-top: 3px; }
.item-conversacion .ic-acciones { display: flex; gap: 8px; flex-shrink: 0; }
.item-conversacion .ic-acciones .btn { padding: 8px 13px; font-size: 12.5px; border-radius: 11px; }
.vacio { color: var(--texto-suave); font-size: 14px; }

/* ===== Curso de inglés ===== */
.curso-progreso { margin-bottom: 18px; }
.cp-texto { font-size: 13px; color: var(--texto-suave); margin-bottom: 6px; font-weight: 600; }
.cp-barra { height: 10px; background: var(--superficie-2); border-radius: 99px; overflow: hidden; }
.cp-fill { height: 100%; width: 0%; background: var(--grad); border-radius: 99px; transition: width 0.4s ease; }

.curso-lista { display: flex; flex-direction: column; gap: 12px; }
.unidad {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 16px;
    overflow: hidden;
    transition: border-color 0.15s ease;
}
.unidad:hover { border-color: rgba(34, 211, 238, 0.35); }
.unidad-cabecera {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 18px;
    cursor: pointer;
    background: none; border: none; width: 100%;
    font-family: inherit; color: var(--texto); text-align: left;
}
.unidad-num {
    width: 38px; height: 38px; flex-shrink: 0;
    display: grid; place-items: center;
    font-weight: 800; font-size: 15px;
    background: var(--grad); color: #06121f;
    border-radius: 12px;
}
.unidad-cabecera h3 { font-size: 15.5px; font-weight: 700; }
.unidad-cabecera .u-ico { margin-left: auto; color: var(--texto-suave); font-size: 13px; transition: transform 0.15s ease; }
.unidad.abierta .u-ico { transform: rotate(180deg); }
.unidad-contenido { display: none; padding: 4px 18px 18px; }
.unidad.abierta .unidad-contenido { display: block; }

.leccion {
    background: var(--superficie-2);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 10px;
}
.leccion h4 { font-size: 14.5px; font-weight: 700; margin-bottom: 6px; }
.leccion p { font-size: 13.5px; color: var(--texto-suave); line-height: 1.65; margin-bottom: 6px; }
.leccion ul, .leccion ol { padding-left: 20px; color: var(--texto-suave); font-size: 13.5px; line-height: 1.6; }
.leccion li { margin: 3px 0; }
.leccion .cita { border-left: 3px solid var(--cian); padding-left: 12px; font-style: italic; color: var(--texto-suave); margin-top: 6px; }
.leccion-marcar {
    display: inline-flex; align-items: center; gap: 8px;
    background: none; border: 1px solid var(--borde);
    color: var(--texto-suave); font-family: inherit; font-size: 12.5px;
    padding: 7px 13px; border-radius: 999px; cursor: pointer; margin-top: 8px;
    transition: all 0.15s ease;
}
.leccion-marcar:hover { border-color: var(--cian); color: var(--texto); }
.leccion.completada .leccion-marcar { background: var(--grad); border: none; color: #06121f; font-weight: 700; }

.examen {
    margin-top: 22px;
    background: linear-gradient(160deg, rgba(167, 139, 250, 0.1), rgba(34, 211, 238, 0.08));
    border: 1px solid rgba(129, 140, 248, 0.35);
    border-radius: var(--radio);
    padding: 20px;
}
.examen h3 { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.examen .ex-sub { font-size: 13px; color: var(--texto-suave); margin-bottom: 16px; }
.pregunta { margin-bottom: 18px; }
.pregunta p { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.pregunta .opciones { display: flex; flex-direction: column; gap: 6px; }
.pregunta .opcion-examen {
    display: flex; align-items: center; gap: 9px;
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--texto);
    cursor: pointer;
    transition: all 0.12s ease;
    text-align: left;
}
.pregunta .opcion-examen:hover { border-color: var(--cian); }
.pregunta .opcion-examen.seleccionada { border-color: var(--violeta); background: color-mix(in srgb, var(--violeta) 15%, transparent); }
.pregunta .opcion-examen.correcta { border-color: var(--verde); background: color-mix(in srgb, var(--verde) 15%, transparent); }
.pregunta .opcion-examen.incorrecta { border-color: var(--rojo); background: color-mix(in srgb, var(--rojo) 15%, transparent); }
.examen-resultado { text-align: center; padding: 14px; border-radius: 12px; margin-top: 8px; font-size: 15px; font-weight: 700; }
.examen-resultado.ok { background: color-mix(in srgb, var(--verde) 18%, transparent); color: var(--verde); }
.examen-resultado.medio { background: color-mix(in srgb, var(--cian) 18%, transparent); color: var(--cian); }
.examen-resultado.mal { background: color-mix(in srgb, var(--rojo) 18%, transparent); color: var(--rojo); }

/* ===== Ajustes ===== */
.ajuste { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.ajuste-info h3 { margin-bottom: 3px; }
.ajuste-info p { font-size: 13px; color: var(--texto-suave); }
.tema-opciones { display: flex; gap: 8px; }
.tema-opcion {
    background: var(--superficie);
    border: 1px solid var(--borde);
    color: var(--texto-suave);
    border-radius: 12px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.tema-opcion.activa { background: var(--grad); border: none; color: #06121f; }

/* ===== Contacto ===== */
.form { display: flex; flex-direction: column; gap: 9px; }
.form label { font-size: 12.5px; font-weight: 700; color: var(--texto-suave); margin-top: 6px; }
.form textarea { min-height: 120px; resize: vertical; font-family: inherit; }
.contacto-exito { margin-top: 12px; font-weight: 700; color: var(--verde); }

/* ===== Footer ===== */
footer {
    border-top: 1px solid var(--borde);
    background: var(--header-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 12px 22px;
    z-index: 10;
}
.footer-cont {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12.5px;
    color: var(--texto-suave);
}
.footer-links { display: flex; gap: 14px; flex-wrap: wrap; }
.link {
    background: none; border: none;
    color: var(--texto-suave);
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.link:hover { color: var(--cian); }

/* ===== FAQ flotante ===== */
.faq-panel {
    position: fixed;
    right: 20px;
    bottom: 64px;
    width: min(420px, 92vw);
    max-height: 60vh;
    overflow-y: auto;
    background: var(--menu-bg);
    border: 1px solid rgba(129, 140, 248, 0.35);
    border-radius: 16px;
    box-shadow: var(--sombra-fuerte);
    padding: 14px;
    z-index: 90;
    animation: aparecer 0.2s ease both;
}
.faq-titulo { font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.faq-item { border-bottom: 1px solid var(--borde); }
.faq-item:last-child { border-bottom: none; }
.faq-q {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; background: none; border: none; color: var(--texto);
    font-family: inherit; font-size: 13px; font-weight: 600;
    padding: 11px 2px; cursor: pointer; text-align: left;
    transition: color 0.15s ease;
}
.faq-q:hover { color: var(--cian); }
.faq-q .flecha { transition: transform 0.18s ease; }
.faq-item.abierto .faq-q .flecha { transform: rotate(180deg); }
.faq-a { display: none; padding: 0 2px 12px; font-size: 13px; color: var(--texto-suave); line-height: 1.6; }
.faq-item.abierto .faq-a { display: block; animation: aparecer 0.2s ease both; }

/* ===== Modales ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(4, 7, 14, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    z-index: 100;
    animation: aparecer 0.2s ease both;
}
.modal {
    background: var(--modal-bg);
    border: 1px solid rgba(129, 140, 248, 0.3);
    border-radius: var(--radio);
    max-width: 640px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--sombra-fuerte);
}
.modal.auth { max-width: 420px; }
.modal-cabecera { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--borde); }
.modal-cabecera h2 { font-size: 17px; font-weight: 800; }
.modal-cuerpo { padding: 18px 22px; overflow-y: auto; font-size: 14px; line-height: 1.7; color: var(--texto-suave); }
.modal-cuerpo h3 { color: var(--texto); font-size: 14.5px; margin: 14px 0 4px; }
.modal-cuerpo h3:first-child { margin-top: 0; }
.modal-cuerpo p { margin-bottom: 8px; }
.modal-cuerpo code { background: var(--codigo-bg); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }

/* ===== Auth ===== */
.auth-form { gap: 8px; }
.auth-nota { font-size: 13px; margin-bottom: 6px; }
.auth-error { color: var(--rojo); font-size: 13px; font-weight: 600; }
.auth-ok { color: var(--verde); font-size: 13px; font-weight: 600; }
.auth-links { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; align-items: center; }
.cuenta-info { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.cuenta-avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; font-size: 22px; }
.cuenta-nombre { font-weight: 800; font-size: 15px; color: var(--texto); }
.cuenta-email { font-size: 12.5px; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
    .tarjetas { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    body { overflow: hidden; }
    .logo-texto p { display: none; }
    .stats { display: none; }
    .sidebar {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        width: 100%; height: 62px;
        flex-direction: row; align-items: center; justify-content: space-around;
        padding: 6px 8px;
        border-top: 1px solid var(--borde);
        border-right: none;
        z-index: 50;
        overflow: visible;
    }
    .nav { flex-direction: row; width: 100%; justify-content: space-around; }
    .nav-item { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 11px; width: auto; }
    .nav-item span { font-size: 11px; }
    .sidebar-pie { display: none; }
    main { padding-bottom: 70px; }
    .barra { flex-wrap: wrap; }
    .dropdown { flex: 1 1 100%; }
    .dropdown-trigger { width: 100%; min-width: 0; }
    .dropdown-menu { width: 100%; }
    .input-wrap { order: 2; flex: 1 1 100%; }
    #btnEnsenar { order: 3; }
    .btn.enviar { order: 4; }
    .columna { max-width: 88%; }
    .footer-cont { justify-content: center; }
    .faq-panel { right: 10px; left: 10px; width: auto; bottom: 70px; }
    .usuario-chip span.uc-nombre { display: none; }
}
