:root {
    /* =====================================================================
       Sistema visual Dr. Notes · "Pastel Innovation" (Clinical SaaS UI)
       Todos los módulos (app, examenes, ultraresumenes) consumen estos tokens.
       ===================================================================== */

    /* Neutros */
    --bg-paper: #F8FAFC;
    --superficie: #FFFFFF;
    --superficie-2: #F1F5F9;
    --text-main: #1E293B;
    --text-2: #475569;
    --text-3: #64748B;
    --ui-grey: #94A3B8;
    --linea: #E2E8F0;
    --linea-suave: #EEF2F7;

    /* Marca: tinta navy para lo primario, azul para lo interactivo */
    --azul-oscuro: #1E3A5F;
    --azul: #2563EB;
    --azul-hover: #1D4ED8;
    --azul-suave: #EFF6FF;
    --azul-borde: #BFDBFE;
    --cian: #0EA5E9;
    --gradiente-ia: linear-gradient(135deg, #1E3A5F 0%, #2563EB 60%, #0EA5E9 100%);

    /* Pasteles por especialidad (identidad Dr. Notes) */
    --gineco-pastel: #FBCFE8;  --gineco-contraste: #9D174D;  --gineco-bg: #FFF5F9;
    --cirugia-pastel: #FDE68A; --cirugia-contraste: #92400E; --cirugia-bg: #FFFDF5;
    --interna-pastel: #A7F3D0; --interna-contraste: #064E3B; --interna-bg: #F6FFF7;
    --pediatria-pastel: #BAE6FD; --pediatria-contraste: #075985; --pediatria-bg: #F5FBFF;

    /* Estados semánticos derivados de los pasteles */
    --ok: #047857;    --ok-bg: #ECFDF5;   --ok-borde: #A7F3D0;   --ok-solido: #10B981;
    --warn: #B45309;  --warn-bg: #FFFBEB; --warn-borde: #FDE68A; --warn-solido: #F59E0B;
    --bad: #BE123C;   --bad-bg: #FFF1F5;  --bad-borde: #FBCFE8;  --bad-solido: #F43F5E;
    --info: #075985;  --info-bg: #F0F9FF; --info-borde: #BAE6FD; --info-solido: #0EA5E9;

    /* Forma */
    --radio-tarjeta: 20px;
    --radio-boton: 12px;
    --radio-chip: 999px;
    --sombra-suave: 0px 10px 15px -3px rgba(0, 0, 0, 0.05);
    --sombra-flotante: 0 24px 48px -24px rgba(15, 23, 42, .25);
    --anillo-foco: 0 0 0 4px rgba(37, 99, 235, .12);

    /* Tipografía: Montserrat (títulos, 500/600) · Inter (cuerpo, 400/500/600) */
    --f-titulo: 'Montserrat', 'Inter', system-ui, sans-serif;
    --f-cuerpo: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

    /* Layout */
    --nav-movil-h: 64px;
}

/* =====================================================================
   Base
   ===================================================================== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--f-cuerpo);
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg-paper);
    color: var(--text-main);
    position: relative;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--f-titulo); font-weight: 600; letter-spacing: -.01em; }
button { font-family: inherit; }
.oculto { display: none !important; }
.app-bloqueada { visibility: hidden; }

/* Badge IA: único elemento con gradiente de marca */
.badge-ia {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--f-cuerpo);
    font-weight: 600;
    font-size: 10.5px;
    letter-spacing: .5px;
    color: white;
    background: var(--gradiente-ia);
    padding: 3px 8px;
    border-radius: 999px;
    vertical-align: middle;
}

/* =====================================================================
   Login: panel de marca (bento) + tarjeta de acceso
   ===================================================================== */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 20px;
    overflow-y: auto;
    background: var(--bg-paper);
}
.login-overlay.oculto { display: none; }
.login-escena {
    width: min(100%, 980px);
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-radius: 28px;
    overflow: hidden;
    box-shadow: var(--sombra-flotante);
}
.login-marca-panel {
    padding: 44px 44px 36px;
    background: var(--superficie-2);
    border-right: 1px solid var(--linea);
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.login-marca-cab { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.login-marca-cab img { height: 44px; width: auto; object-fit: contain; }
.login-marca-cab span { font: 600 14px var(--f-titulo); color: var(--azul-oscuro); letter-spacing: .2px; }
.login-marca-panel h2 { margin: 0; font: 600 28px/1.2 var(--f-titulo); color: var(--text-main); letter-spacing: -.02em; max-width: 380px; }
.login-marca-panel > p { margin: 0; color: var(--text-3); font-size: 14px; line-height: 1.6; max-width: 400px; }
.login-bento { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.login-tile {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    border-radius: 18px;
    border: 1px solid transparent;
}
.login-tile svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 8px; }
.login-tile b { font: 600 14px var(--f-titulo); }
.login-tile span { font-size: 12.5px; line-height: 1.45; opacity: .85; }
.tile-sky   { background: var(--pediatria-bg); border-color: var(--pediatria-pastel); color: var(--pediatria-contraste); }
.tile-mint  { background: var(--interna-bg);   border-color: var(--interna-pastel);   color: var(--interna-contraste); }
.tile-rose  { background: var(--gineco-bg);    border-color: var(--gineco-pastel);    color: var(--gineco-contraste); }
.tile-amber { background: var(--cirugia-bg);   border-color: var(--cirugia-pastel);   color: var(--cirugia-contraste); }
.login-marca-pie { margin: auto 0 0 !important; padding-top: 18px; font-size: 11.5px !important; color: var(--ui-grey) !important; }

.login-card {
    padding: 44px 40px 32px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-logo { height: 46px; width: auto; object-fit: contain; }
.login-producto { display: inline-flex; align-items: center; gap: 8px; font: 600 18px var(--f-titulo); letter-spacing: -.01em; }
.login-copy { margin-bottom: 14px; }
.login-copy h1 { margin: 0 0 4px; font: 600 26px var(--f-titulo); letter-spacing: -.02em; }
.login-copy p { margin: 0; color: var(--text-3); font-size: 14px; }
.login-card label { font-size: 13px; font-weight: 500; color: var(--text-2); margin-top: 6px; }
.login-input-wrap { position: relative; display: flex; align-items: center; }
.login-input-wrap > svg { position: absolute; left: 14px; width: 18px; height: 18px; fill: none; stroke: var(--ui-grey); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.login-input-wrap input {
    width: 100%;
    border: 1px solid var(--linea);
    border-radius: var(--radio-boton);
    padding: 13px 44px 13px 42px;
    font: 15px var(--f-cuerpo);
    color: var(--text-main);
    outline: none;
    background: var(--superficie);
    transition: border-color .2s, box-shadow .2s;
}
.login-input-wrap input::placeholder { color: var(--ui-grey); }
.login-input-wrap input:focus { border-color: var(--azul); box-shadow: var(--anillo-foco); }
.login-input-wrap select {
    width: 100%;
    border: 1px solid var(--linea);
    border-radius: var(--radio-boton);
    padding: 13px 40px 13px 42px;
    font: 15px var(--f-cuerpo);
    color: var(--text-main);
    outline: none;
    background: var(--superficie);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    transition: border-color .2s, box-shadow .2s;
}
.login-input-wrap select:focus { border-color: var(--azul); box-shadow: var(--anillo-foco); }
.btn-ver-password { position: absolute; right: 7px; width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 9px; color: var(--text-3); background: transparent; cursor: pointer; }
.btn-ver-password:hover { background: var(--azul-suave); color: var(--azul); }
.btn-ver-password svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.login-card .btn-login {
    margin-top: 14px;
    border: 0;
    border-radius: var(--radio-boton);
    padding: 13px;
    color: white;
    background: var(--azul-oscuro);
    font: 600 14.5px var(--f-cuerpo);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 8px 16px -10px rgba(30, 58, 95, .5);
    transition: background .18s, transform .18s;
}
.login-card .btn-login:hover { background: #16304F; transform: translateY(-1px); }
.login-card .btn-login svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.login-card .btn-login:disabled { opacity: .6; cursor: wait; transform: none; }
.login-error { min-height: 18px; margin: 4px 0 0; color: var(--bad); text-align: center; font-size: 13px; }
.login-seguridad { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--ui-grey); font-size: 11px; }
.login-seguridad svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* =====================================================================
   App shell: cabecera única (marca · navegación · acciones)
   ===================================================================== */
.app {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.app-header {
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding: 10px 24px;
    background: var(--superficie);
    border-bottom: 1px solid var(--linea);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { height: 40px; width: auto; object-fit: contain; display: block; }
.brand-textos h1 { margin: 0; font: 600 16px var(--f-titulo); color: var(--text-main); display: flex; align-items: center; gap: 8px; letter-spacing: -.01em; }
.brand-textos p { margin: 1px 0 0; font-size: 12px; color: var(--text-3); font-weight: 400; }
.header-acciones { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.cuota-chat {
    padding: 6px 11px;
    border: 1px solid var(--info-borde);
    border-radius: 999px;
    color: var(--info);
    background: var(--info-bg);
    font-size: 11.5px;
    font-weight: 500;
    white-space: nowrap;
}
.btn-logout-chat {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--linea);
    border-radius: 10px;
    background: var(--superficie);
    color: var(--text-2);
    padding: 8px 12px;
    font: 500 12.5px var(--f-cuerpo);
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.btn-logout-chat svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn-logout-chat:hover { color: var(--azul-oscuro); border-color: var(--azul-borde); background: var(--azul-suave); }

/* Navegación principal: control segmentado */
.tabs-app {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--superficie-2);
    border-radius: 999px;
    justify-self: center;
}
.tab-app {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-3);
    font: 500 13.5px var(--f-cuerpo);
    cursor: pointer;
    white-space: nowrap;
    transition: color .18s, background .18s, box-shadow .18s;
}
.tab-app svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab-app:hover { color: var(--azul-oscuro); }
.tab-app.activo { color: var(--azul-oscuro); background: var(--superficie); font-weight: 600; box-shadow: var(--sombra-suave); }
.tab-app:focus-visible { outline: none; box-shadow: var(--anillo-foco); }
.tab-app .corto { display: none; }
.tab-pro { display: inline-grid; place-items: center; padding: 2px 6px; border-radius: 999px; background: var(--azul-oscuro); color: #fff; font: 700 9.5px var(--f-cuerpo); letter-spacing: .6px; line-height: 1.2; }

@media (max-width: 1400px) and (min-width: 901px) {
    .app-header { grid-template-columns: auto auto 1fr; gap: 12px; padding: 10px 18px; }
    .brand-textos p { display: none; }
    .tab-app { padding: 8px 12px; gap: 6px; font-size: 13px; }
}
@media (max-width: 1180px) and (min-width: 901px) {
    .tab-app .largo { display: none; }
    .tab-app .corto { display: inline; }
}

/* Anchos de contenido por módulo (los paneles centran su propio contenido) */
.chat-wrap, .panel-examenes, .panel-ultra, .panel-progreso { width: 100%; }
.chat-wrap { max-width: 900px; margin: 0 auto; }
.panel-examenes > .ex-raiz { max-width: 1120px; margin: 0 auto; }
.panel-ultra > .ur-raiz { max-width: 1440px; margin: 0 auto; }
.panel-ultra.lector > .ur-raiz { max-width: none; }

/* =====================================================================
   Chat
   ===================================================================== */
.chat-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 24px 16px;
    gap: 14px;
    min-height: 0;
    overflow: hidden;
}
.chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 4px 4px 12px;
    overflow-y: auto;
    min-height: 0;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}
.msg { scroll-margin-top: 12px; display: flex; gap: 12px; align-items: flex-end; animation: aparecer .3s ease both; }
.msg-user { justify-content: flex-end; }
@keyframes aparecer { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.avatar { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border-radius: 50%; overflow: hidden; background: var(--superficie-2); }
.avatar-bot img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }

.msg-bubble {
    max-width: 76%;
    padding: 14px 18px;
    border-radius: var(--radio-tarjeta);
    line-height: 1.65;
    font-size: 15px;
}
.msg-bubble p { margin: 0 0 10px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 6px 0 10px; padding-left: 22px; }
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble strong { font-weight: 600; }
.msg-bubble b.gpc-cita { background: var(--azul-suave); color: var(--azul-oscuro); padding: 1px 6px; border-radius: 6px; font-weight: 500; font-size: .92em; }
.msg-bot .msg-bubble { background: var(--superficie); border: 1px solid var(--linea); border-bottom-left-radius: 6px; color: var(--text-main); box-shadow: var(--sombra-suave); }
.msg-user .msg-bubble { background: var(--azul-oscuro); color: white; border-bottom-right-radius: 6px; white-space: pre-wrap; }

.chat-sugerencias {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 4px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.chat-sugerencias::-webkit-scrollbar { display: none; }
.chat-sugerencias button {
    flex: 0 0 auto;
    min-width: max-content;
    scroll-snap-align: start;
    border: 1px solid var(--linea);
    border-radius: 999px;
    background: var(--superficie);
    color: var(--text-2);
    padding: 10px 14px;
    font: 500 13px var(--f-cuerpo);
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s, transform .15s;
    box-shadow: var(--sombra-suave);
}
.chat-sugerencias button:hover { border-color: var(--azul-borde); background: var(--azul-suave); color: var(--azul-oscuro); transform: translateY(-1px); }

.fuentes { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--linea-suave); display: flex; flex-direction: column; gap: 6px; }
.fuentes-titulo { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); font-weight: 500; }
.fuente-item { font-size: 13px; background: var(--azul-suave); border: 1px solid var(--azul-borde); border-radius: 12px; padding: 9px 12px; color: var(--azul-oscuro); display: flex; align-items: flex-start; gap: 10px; }
.fuente-item b { color: var(--azul-oscuro); font-weight: 600; }
.fuente-numero { width: 24px; height: 24px; flex: 0 0 24px; border-radius: 8px; display: grid; place-items: center; color: white; background: var(--azul-oscuro); font-weight: 600; font-size: 12px; }
.fuente-contenido { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fuente-contenido > span:not(.gpc-sello) { color: var(--text-2); }
.fuente-contenido small { color: var(--text-3); line-height: 1.35; }

.no-encontrado .msg-bubble { background: var(--cirugia-bg); border-color: var(--cirugia-pastel); color: var(--cirugia-contraste); }
.escribiendo .msg-bubble { color: var(--text-3); font-style: italic; }
.puntos-escribiendo { display: inline-flex; gap: 3px; margin-left: 4px; vertical-align: middle; }
.puntos-escribiendo span { width: 5px; height: 5px; border-radius: 50%; background: var(--ui-grey); animation: rebote 1.2s infinite ease-in-out; }
.puntos-escribiendo span:nth-child(2) { animation-delay: .15s; }
.puntos-escribiendo span:nth-child(3) { animation-delay: .3s; }
@keyframes rebote { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }

.composer {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: stretch;
    background: var(--superficie);
    border: 1px solid var(--linea);
    border-radius: 18px;
    padding: 8px 8px 8px 18px;
    box-shadow: var(--sombra-suave);
    transition: box-shadow .2s, border-color .2s;
    flex: 0 0 auto;
    position: relative;
    z-index: 5;
}
.composer:focus-within { border-color: var(--azul); box-shadow: var(--anillo-foco); }
.composer textarea { flex: 1; display: block; width: 100%; min-width: 0; min-height: 46px; border: none; outline: none; resize: none; font-family: var(--f-cuerpo); font-size: 15px; line-height: 1.5; max-height: 160px; padding: 9px 4px; background: transparent; color: var(--text-main); }
.composer textarea::placeholder { color: var(--ui-grey); }
.composer-side { position: relative; display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 8px; flex: 0 0 auto; }
.composer .composer-submit {
    background: var(--azul-oscuro);
    color: white;
    border: none;
    border-radius: var(--radio-boton);
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s, transform .15s;
}
.composer .composer-submit:hover { background: #16304F; transform: translateY(-1px); }
.composer .composer-submit:active { transform: scale(.97); }
.composer .composer-submit:disabled { opacity: .45; cursor: default; transform: none; }
.disclaimer { font-size: 11.5px; color: var(--ui-grey); text-align: center; margin: 0; flex: 0 0 auto; line-height: 1.5; }

/* ---------- Flashcard: botón dentro de la respuesta ---------- */
.btn-flashcard-mini {
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--azul-borde);
    background: var(--superficie);
    color: var(--azul-oscuro);
    font: 500 12.5px var(--f-cuerpo);
    padding: 7px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn-flashcard-mini svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn-flashcard-mini:hover { background: var(--azul-suave); border-color: var(--azul); }
.btn-flashcard-mini:disabled { opacity: .6; cursor: wait; }
.msg-bubble .btn-ver-flashcard {
    margin-top: 10px;
    border: none;
    border-radius: var(--radio-boton);
    padding: 10px 16px;
    color: white;
    background: var(--azul-oscuro);
    font: 500 13px var(--f-cuerpo);
    cursor: pointer;
    transition: background .15s;
}
.msg-bubble .btn-ver-flashcard:hover { background: #16304F; }

/* ---------- Modal de flashcard ---------- */
.flashcard-overlay {
    position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px 16px; overflow-y: auto;
    background: rgba(15, 23, 42, .5); backdrop-filter: blur(6px); opacity: 0; transition: opacity .22s ease;
}
.flashcard-overlay.oculto { display: none; }
.flashcard-overlay.flashcard-visible { opacity: 1; }
.flashcard-panel {
    position: relative; width: min(94vw, 520px); margin: auto; display: flex; flex-direction: column; align-items: center; gap: 16px;
    transform: translateY(14px) scale(.97); opacity: 0; transition: transform .28s cubic-bezier(.2,.8,.2,1), opacity .28s ease;
}
.flashcard-visible .flashcard-panel { transform: none; opacity: 1; }
.flashcard-cerrar {
    position: absolute; top: -14px; right: -14px; width: 34px; height: 34px; border-radius: 50%; border: none; background: white; color: var(--text-main);
    font-size: 20px; line-height: 1; box-shadow: var(--sombra-flotante); cursor: pointer; z-index: 2; transition: transform .15s;
}
.flashcard-cerrar:hover { transform: scale(1.08); }
.flashcard-render-wrap { width: 100%; }
.flashcard-acciones { width: 100%; }
.btn-flashcard-guardar { width: 100%; margin-top: 8px; border: 1px solid var(--linea); border-radius: var(--radio-boton); padding: 11px; color: var(--azul-oscuro); background: var(--superficie); font: 500 13px var(--f-cuerpo); cursor: pointer; }
.btn-flashcard-guardar:hover, .btn-flashcard-guardar.guardada { border-color: var(--ok-borde); background: var(--ok-bg); color: var(--ok); }
.btn-flashcard-descargar {
    width: 100%; border: none; border-radius: var(--radio-boton); padding: 13px; color: white; background: var(--azul-oscuro);
    font: 600 14px var(--f-cuerpo); cursor: pointer; box-shadow: 0 8px 16px -10px rgba(30, 58, 95, .5); transition: background .15s, transform .15s;
}
.btn-flashcard-descargar:hover { background: #16304F; transform: translateY(-1px); }
.btn-flashcard-descargar:disabled { opacity: .65; cursor: wait; transform: none; }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 900px) {
    .login-escena { grid-template-columns: 1fr; width: min(100%, 440px); border-radius: 24px; }
    .login-marca-panel { display: none; }
    .login-card { padding: 34px 28px 26px; }
}

@media (max-width: 720px) {
    .app-header { grid-template-columns: 1fr auto; padding: 10px 16px; gap: 10px; }
    .brand-logo { height: 36px; }
    .brand-textos p { display: none; }
    .btn-logout-chat span { display: none; }
    .btn-logout-chat { padding: 8px; }

    /* Navegación inferior fija (zona del pulgar) */
    .tabs-app {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        width: 100%;
        justify-self: stretch;
        z-index: 50;
        height: calc(var(--nav-movil-h) + env(safe-area-inset-bottom, 0px));
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
        border-radius: 0;
        background: var(--superficie);
        border-top: 1px solid var(--linea);
    }
    .tab-app { flex-direction: column; justify-content: center; gap: 3px; padding: 4px 6px; border-radius: 12px; font-size: 11px; font-weight: 500; }
    .tab-app svg { width: 21px; height: 21px; }
    .tab-app.activo { background: var(--azul-suave); box-shadow: none; }
    .tab-app .largo { display: none; }
    .tab-app .corto { display: inline; }
    .tab-progreso { position: relative; }
    .tab-progreso .tab-pro { position: absolute; top: 2px; right: calc(50% - 26px); padding: 1px 4px; font-size: 8px; }

    .chat-wrap { padding: 14px 14px calc(var(--nav-movil-h) + 10px + env(safe-area-inset-bottom, 0px)); gap: 10px; }
    .panel-examenes, .panel-ultra, .panel-progreso { padding-bottom: calc(var(--nav-movil-h) + 24px + env(safe-area-inset-bottom, 0px)); }
    .msg-bubble { max-width: 86%; font-size: 14.5px; padding: 12px 15px; }
    .avatar { width: 34px; height: 34px; }
    .chat-sugerencias { padding: 0 0 4px; }
    .chat-sugerencias button { font-size: 12.5px; padding: 9px 12px; }
    .btn-flashcard-mini { width: 100%; justify-content: center; }
    .disclaimer { font-size: 10.5px; }
    .flashcard-overlay { padding-bottom: calc(24px + var(--nav-movil-h)); }
}

@media (max-width: 380px) {
    .composer { padding: 6px 8px 8px 12px; }
    .composer-side { gap: 6px; }
    .act-opcion { padding-right: 10px; gap: 6px; font-size: 12px; }
    .act-opcion .corto { display: none; }
}

@media (max-height: 700px) {
    .flashcard-overlay { align-items: flex-start; padding-top: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .msg, .puntos-escribiendo span { animation: none; }
    .flashcard-overlay, .flashcard-panel, .flashcard-cerrar, .btn-flashcard-mini, .btn-flashcard-descargar, .tab-app { transition: none; }
}

/* =====================================================================
   Actualizaciones de fuentes recientes (nota bajo la respuesta de la GPC)
   ===================================================================== */
/* Búsqueda avanzada: interruptor discreto dentro del compositor */
.act-opcion { position: relative; display: inline-flex; align-items: center; gap: 8px; min-width: 0; min-height: 36px; padding: 0 12px 0 8px; border: 1px solid var(--linea); border-radius: 999px; background: var(--superficie); font: 500 12.5px var(--f-cuerpo); color: var(--text-2); cursor: pointer; user-select: none; transition: border-color .15s, background .15s, color .15s; }
.act-opcion:hover { border-color: var(--azul-borde); color: var(--azul-oscuro); }
.act-opcion input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.act-switch { position: relative; flex: none; width: 28px; height: 16px; border-radius: 999px; background: var(--linea); transition: background .15s; }
.act-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .25); transition: transform .15s; }
.act-ico { flex: none; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.act-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-txt small { font-size: 11.5px; font-weight: 400; color: var(--text-3); }
.act-opcion input:checked ~ .act-switch { background: var(--azul); }
.act-opcion input:checked ~ .act-switch::after { transform: translateX(12px); }
.act-opcion:has(input:checked) { border-color: var(--azul-borde); background: var(--azul-suave); color: var(--azul-oscuro); }
.act-opcion input:focus-visible ~ .act-switch { outline: 2px solid var(--azul); outline-offset: 2px; }
.composer-side { justify-content: space-between; }
.composer-side .composer-submit { margin-left: auto; }
.ico-inline { display: inline-block; width: 1em; height: 1em; vertical-align: -.14em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico-alerta { color: var(--warn); margin-right: 2px; }
.badge-ia .ico-inline { width: 11px; height: 11px; }

.act-slot { margin-top: 12px; }
.act-cargando { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); }
.act-cargando .puntos-escribiendo { transform: scale(.8); transform-origin: left center; }

.act-card { border: 1px solid var(--warn-borde); background: var(--warn-bg); border-radius: 14px; padding: 12px 14px; font-size: 13px; line-height: 1.5; }
.act-cab { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.act-cab b { font-family: var(--f-titulo); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--warn); }
.act-cab span { font-size: 11.5px; color: var(--text-3); }
.act-item + .act-item { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--warn-borde); }
.act-tema { font-weight: 600; color: var(--text-main); margin-bottom: 5px; }
.act-fila { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: baseline; margin-bottom: 4px; }
.act-etq { display: inline-block; justify-self: start; max-width: 100%; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-etq-gpc { background: var(--superficie); color: var(--text-2); border: 1px solid var(--linea); }
.act-etq-fuente { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-borde); }
.act-texto { color: var(--text-main); }
.act-enlace { display: inline-block; margin-top: 3px; font-size: 12px; color: var(--azul); text-decoration: none; word-break: break-word; }
.act-enlace:hover { text-decoration: underline; }
.act-pie { margin-top: 10px; font-size: 11px; color: var(--text-3); }

@media (max-width: 560px) {
    .act-fila { grid-template-columns: 1fr; gap: 3px; }
}

/* =====================================================================
   Tablas y algoritmos con diseño predefinido (el modelo solo entrega datos compactos)
   ===================================================================== */
.msg-bubble { min-width: 0; }
.msg-bot.msg-ancho .msg-bubble { max-width: 100%; flex: 1 1 auto; }
.msg-codigo { margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: var(--superficie-2); font-size: 12.5px; overflow-x: auto; white-space: pre-wrap; }

.pro-fig { margin: 12px 0 6px; border: 1px solid var(--linea); border-radius: 16px; background: var(--superficie); overflow: hidden; box-shadow: var(--sombra-suave); }
.pro-barra { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 12px; background: var(--superficie-2); border-bottom: 1px solid var(--linea); }
.pro-etq { display: inline-flex; align-items: center; gap: 6px; font: 600 11px var(--f-titulo); text-transform: uppercase; letter-spacing: .6px; color: var(--azul-oscuro); }
.pro-etq svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.pro-acc { display: inline-flex; gap: 6px; }
.pro-btn { border: 1px solid var(--linea); background: var(--superficie); border-radius: 999px; padding: 3px 11px; font: 500 11.5px var(--f-cuerpo); color: var(--text-2); cursor: pointer; transition: border-color .15s, background .15s, color .15s; }
.pro-btn:hover:not(:disabled) { border-color: var(--azul-borde); background: var(--azul-suave); color: var(--azul); }
.pro-btn:disabled { opacity: .6; cursor: default; }
.pro-captura { background: #FFFFFF; }
.pro-pie { padding: 5px 12px 8px; text-align: right; font-size: 10.5px; letter-spacing: .3px; color: var(--ui-grey); }

/* Tabla */
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl-datos { width: 100%; min-width: 460px; border-collapse: separate; border-spacing: 0; font-size: 13.5px; line-height: 1.5; }
.tbl-datos thead th { background: var(--azul-oscuro); color: #FFFFFF; text-align: left; padding: 10px 14px; font: 600 11.5px var(--f-titulo); text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.tbl-datos thead th + th { border-left: 1px solid rgba(255, 255, 255, .14); }
.tbl-datos tbody th, .tbl-datos tbody td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--linea-suave); }
.tbl-datos tbody th { width: 22%; min-width: 120px; background: var(--azul-suave); color: var(--azul-oscuro); font-weight: 600; position: sticky; left: 0; z-index: 1; }
.tbl-datos tbody td + td { border-left: 1px solid var(--linea-suave); }
.tbl-datos tbody tr:nth-child(even) td { background: #FAFBFD; }
.tbl-datos tbody tr:hover td { background: #F3F8FF; }
.tbl-datos tbody tr:last-child th, .tbl-datos tbody tr:last-child td { border-bottom: 0; }
.tbl-vacio { color: var(--ui-grey); }

/* Algoritmo */
.alg-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 18px 14px 8px; }
.alg-escala { margin: 0 auto; }
.alg-lienzo { width: max-content; transform-origin: top left; display: flex; flex-direction: column; align-items: center; }
.alg-nodo { display: flex; flex-direction: column; align-items: center; }
.alg-caja { display: flex; align-items: center; gap: 8px; min-width: 130px; max-width: 250px; padding: 9px 13px; border: 1px solid var(--linea); border-radius: 12px; background: var(--superficie); font-size: 13px; line-height: 1.4; text-align: left; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); }
.alg-ico { flex: 0 0 auto; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font: 700 11px var(--f-cuerpo); }
.alg-inicio { background: var(--azul-oscuro); border-color: var(--azul-oscuro); color: #FFFFFF; border-radius: 999px; font-weight: 600; padding-right: 16px; }
.alg-inicio .alg-ico { background: rgba(255, 255, 255, .18); }
.alg-decision { background: var(--warn-bg); border-color: var(--warn-borde); color: var(--text-main); font-weight: 600; }
.alg-decision .alg-ico { background: var(--warn-solido); color: #FFFFFF; }
.alg-accion { border-color: var(--azul-borde); border-left: 4px solid var(--azul); }
.alg-accion .alg-ico { background: var(--azul-suave); color: var(--azul); }
.alg-resultado { background: var(--ok-bg); border-color: var(--ok-borde); color: var(--ok); font-weight: 600; }
.alg-resultado .alg-ico { background: var(--ok-solido); color: #FFFFFF; }
.alg-nota { background: var(--superficie-2); border-style: dashed; color: var(--text-3); font-size: 12px; box-shadow: none; }
.alg-nota .alg-ico { background: var(--linea); color: var(--text-2); }

.alg-flecha { position: relative; width: 2px; height: 20px; margin: 0 auto; background: #94A3B8; }
.alg-flecha:not(.alg-linea)::after { content: ''; position: absolute; left: -4px; bottom: -1px; border: 5px solid transparent; border-top: 7px solid #94A3B8; border-bottom: 0; }
.alg-ramas { display: flex; justify-content: center; align-items: flex-start; }
.alg-rama { position: relative; display: flex; flex-direction: column; align-items: center; padding: 20px 8px 0; }
.alg-rama::before, .alg-rama::after { content: ''; position: absolute; top: 0; width: 50%; height: 20px; border-top: 2px solid #94A3B8; }
.alg-rama::before { right: 50%; }
.alg-rama::after { left: 50%; border-left: 2px solid #94A3B8; }
.alg-rama:first-child::before { border-top: 0; }
.alg-rama:last-child::after { border-top: 0; }
.alg-rama:only-child::before { display: none; }
.alg-etq { position: relative; z-index: 1; margin: 0 0 7px; padding: 1px 10px; border: 1px solid var(--linea); border-radius: 999px; background: var(--superficie-2); font: 600 11px var(--f-cuerpo); color: var(--text-2); white-space: nowrap; }
.alg-etq.si { background: var(--ok-bg); border-color: var(--ok-borde); color: var(--ok); }
.alg-etq.no { background: var(--bad-bg); border-color: var(--bad-borde); color: var(--bad); }

@media (max-width: 640px) {
    .tbl-datos thead th, .tbl-datos tbody th, .tbl-datos tbody td { padding: 8px 10px; }
    .tbl-datos { font-size: 13px; }
}

/* Marca Dr. Notes en los algoritmos (lo que se ve es lo que se exporta como imagen) */
.alg-captura { position: relative; overflow: hidden; border-top: 5px solid var(--azul-oscuro); }
.alg-captura > * { position: relative; z-index: 1; }
.alg-captura > .alg-marca-agua { position: absolute; z-index: 0; left: 50%; top: 52%; width: 46%; max-width: 380px; transform: translate(-50%, -50%); opacity: .045; pointer-events: none; }
.alg-cab { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--linea); background: linear-gradient(180deg, #F8FAFC, #FFFFFF); }
.alg-logo { height: 40px; width: auto; flex: 0 0 auto; display: block; }
.alg-cab-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.alg-kicker { font: 600 10px var(--f-cuerpo); letter-spacing: .7px; text-transform: uppercase; color: var(--text-3); }
.alg-titulo { font: 600 15px/1.3 var(--f-titulo); color: var(--azul-oscuro); }
.alg-pie { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; align-items: center; padding: 9px 16px 11px; border-top: 1px solid var(--linea); background: #F8FAFC; font-size: 10.5px; color: var(--text-3); }
.alg-firma { display: inline-flex; align-items: center; gap: 6px; font: 600 11px var(--f-titulo); color: var(--azul-oscuro); }
.alg-firma img { height: 18px; width: auto; }
.alg-origen { text-align: right; color: var(--text-2); }
.alg-url { color: var(--ui-grey); }
.alg-aviso { text-align: right; color: var(--ui-grey); }
@media (max-width: 640px) {
    .alg-cab { padding: 10px 12px; gap: 9px; }
    .alg-logo { height: 32px; }
    .alg-titulo { font-size: 13.5px; }
    .alg-pie { grid-template-columns: 1fr; gap: 2px; padding: 8px 12px 10px; }
    .alg-origen, .alg-aviso { text-align: left; }
}

/* =====================================================================
   Pie discreto, aviso inicial dentro del chat y mensajes de espera
   ===================================================================== */
.chat { overflow-anchor: none; }
.disclaimer { font-size: 10.5px; line-height: 1.3; padding: 0; opacity: .85; }
.chat-aviso { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 2px 54px; padding: 0; font-size: 12px; line-height: 1.45; color: var(--text-3); }
.chat-aviso svg { flex: none; width: 15px; height: 15px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.act-opcion .corto { display: none; }

.escribiendo .msg-bubble.espera { font-style: normal; color: var(--text-2); }
.espera-estado { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.espera-texto { animation: aparecer .25s ease both; }
.espera-frase { margin-top: 8px; padding-left: 10px; border-left: 2px solid var(--azul-borde); font-size: 12.5px; line-height: 1.45; color: var(--text-3); animation: aparecer .5s ease both; }

@media (max-width: 720px) {
    .act-opcion .largo { display: none; }
    .act-opcion .corto { display: inline; }
    .chat-aviso { margin-left: 44px; font-size: 11.5px; }
    .chat-wrap { gap: 6px; padding-top: 10px; }
    .composer { margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) { .espera-texto, .espera-frase { animation: none; } }


/* Pantalla completa del algoritmo */
.alg-pro .alg-scroll { cursor: zoom-in; }
.pro-btn-fs { display: inline-flex; align-items: center; gap: 5px; }
.pro-btn-fs svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.alg-fs { position: fixed; inset: 0; z-index: 2000; display: flex; flex-direction: column; background: #F1F5F9; }
.alg-fs-barra { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; background: var(--superficie); border-bottom: 1px solid var(--linea); }
.alg-fs-titulo { flex: 1; min-width: 0; font: 600 14px var(--f-titulo); color: var(--azul-oscuro); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alg-fs-acciones { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.alg-fs-acciones button { min-width: 36px; height: 36px; padding: 0 10px; border: 1px solid var(--linea); border-radius: 10px; background: var(--superficie); font: 500 18px/1 var(--f-cuerpo); color: var(--text-2); cursor: pointer; }
.alg-fs-acciones button.alg-fs-txt { font-size: 12.5px; }
.alg-fs-acciones button:hover:not(:disabled) { border-color: var(--azul-borde); background: var(--azul-suave); color: var(--azul); }
.alg-fs-acciones button:disabled { opacity: .6; }
.alg-fs-acciones .alg-fs-cerrar { background: var(--azul-oscuro); border-color: var(--azul-oscuro); color: #fff; font-size: 16px; }
.alg-fs-acciones .alg-fs-cerrar:hover { background: #16304F; color: #fff; }
.alg-fs-zoom { min-width: 44px; text-align: center; font: 600 12.5px var(--f-cuerpo); color: var(--text-2); }
.alg-fs-vista { position: relative; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; padding: 12px 12px calc(16px + env(safe-area-inset-bottom, 0px)); outline: none; }
.alg-fs-fig { margin: 0 auto; border-radius: 14px; overflow: visible; box-shadow: var(--sombra-suave); width: max-content; min-width: 100%; }
.alg-fs-fig .pro-barra { display: none; }
.alg-fs-fig .alg-scroll { overflow: visible; cursor: default; }
.alg-fs-fig .alg-captura { overflow: visible; }
@media (max-width: 640px) {
    .alg-fs-barra { padding-left: 8px; padding-right: 8px; }
    .alg-fs-titulo { display: none; }
    .alg-fs-acciones { width: 100%; flex-wrap: nowrap; justify-content: space-between; gap: 4px; }
    .alg-fs-acciones button { min-width: 34px; padding: 0 7px; }
    .alg-fs-acciones button.alg-fs-txt { font-size: 12px; }
    .alg-fs-zoom { min-width: 38px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) { .alg-fs { transition: none; } }

/* Fuentes colapsables (más de 2 GPC) */
.fuentes-colapsable > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.fuentes-colapsable > summary::-webkit-details-marker { display: none; }
.fuentes-colapsable > summary::after { content: ''; width: 12px; height: 12px; flex: none; margin-left: auto; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center/12px no-repeat; transition: transform .15s; }
.fuentes-colapsable[open] > summary::after { transform: rotate(180deg); }
.fuentes-n { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--azul-suave); color: var(--azul-oscuro); font-size: 10.5px; font-weight: 600; letter-spacing: 0; }
.fuentes-colapsable[open] > summary { margin-bottom: 6px; }

/* Barra de tablas y algoritmos: nada se corta en celular */
.pro-barra { flex-wrap: wrap; row-gap: 6px; }
.pro-acc { flex-wrap: wrap; justify-content: flex-end; }
.pro-btn-fs, .pro-btn-icono { display: inline-grid; place-items: center; width: 30px; height: 26px; padding: 0; }
.pro-btn-fs svg, .pro-btn-icono svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------- Tablas: texto centrado, primera columna a la izquierda, marca de agua ---------------- */
.tbl-captura { position: relative; overflow: hidden; }
.tbl-captura > .tbl-scroll, .tbl-captura > .pro-pie { position: relative; z-index: 1; }
.tbl-captura > .tbl-marca-agua { position: absolute; z-index: 2; left: 50%; top: 50%; height: 72%; width: auto; max-width: 50%; object-fit: contain; transform: translate(-50%, -50%); opacity: .04; pointer-events: none; }
.tbl-datos thead th { text-align: center; }
.tbl-datos thead th:first-child { text-align: left; }
.tbl-datos tbody td { text-align: center; vertical-align: middle; }
.tbl-datos tbody th { text-align: left; vertical-align: middle; }
.tbl-datos ul, .tbl-datos ol { text-align: left; }
.tbl-lienzo { display: block; width: max-content; }
.tbl-lienzo .tbl-datos { min-width: 0; width: auto; }

/* ---------------- Tablas complementarias de un algoritmo (compactas) ---------------- */
.alg-lienzo { position: relative; }
.alg-comp-fila { position: relative; z-index: 1; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; padding: 4px 16px 14px; }
.alg-comp { width: max-content; max-width: 420px; border: 1px solid var(--linea); border-radius: 12px; background: #FFFFFF; overflow: hidden; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); }
.alg-comp.flotante { position: absolute; z-index: 2; margin: 0; }
.alg-comp-tit { display: flex; flex-direction: column; gap: 1px; margin: 0; padding: 7px 11px; border-bottom: 1px solid var(--linea); background: var(--azul-suave); font: 600 12px var(--f-titulo); color: var(--azul-oscuro); }
.alg-comp-tit span { font: 600 8.5px var(--f-cuerpo); letter-spacing: .6px; text-transform: uppercase; color: var(--text-3); }
.alg-comp .tbl-scroll { overflow: visible; }
.alg-comp .tbl-datos { min-width: 0; width: auto; font-size: 11.5px; line-height: 1.35; }
.alg-comp .tbl-datos thead th { background: var(--azul); padding: 6px 10px; font-size: 9.5px; white-space: normal; }
.alg-comp .tbl-datos tbody th, .alg-comp .tbl-datos tbody td { padding: 6px 10px; }
.alg-comp .tbl-datos tbody th { width: auto; min-width: 0; position: static; }

/* ---------------- Árbol horizontal (izquierda → derecha) ---------------- */
.alg-h .alg-lienzo { flex-direction: row; align-items: center; }
.alg-h .alg-escala { margin: 0 auto; }
.alg-h .alg-nodo { flex-direction: row; align-items: center; }
.alg-h .alg-flecha { width: 24px; height: 2px; margin: 0; flex: 0 0 auto; }
.alg-h .alg-flecha:not(.alg-linea)::after { left: auto; right: -1px; bottom: auto; top: -4px; border: 5px solid transparent; border-left: 7px solid #94A3B8; border-right: 0; }
.alg-h .alg-ramas { flex-direction: column; align-items: flex-start; justify-content: center; }
.alg-h .alg-rama { flex-direction: row; align-items: center; padding: 6px 0 6px 24px; }
.alg-h .alg-rama::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 0; height: auto; right: auto; border-top: 0; border-left: 2px solid #94A3B8; }
.alg-h .alg-rama::after { content: ''; position: absolute; left: 0; top: 50%; width: 24px; height: 0; border-top: 2px solid #94A3B8; border-left: 0; }
.alg-h .alg-rama:first-child::before { top: 50%; border-top: 0; }
.alg-h .alg-rama:last-child::before { bottom: 50%; border-top: 0; }
.alg-h .alg-rama:only-child::before { display: none; }
.alg-h .alg-rama:last-child::after { border-top: 2px solid #94A3B8; }
.alg-h .alg-etq { margin: 0 8px 0 0; flex: 0 0 auto; }

/* Barra de la pantalla completa: botón de orientación con ícono */
.alg-fs-acciones button.alg-fs-ico { padding: 0 8px; }
.alg-fs-acciones button.alg-fs-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* Búsqueda avanzada: el dato reciente se presenta como tabla comparativa */
.act-tabla { border: 1px solid var(--warn-borde); border-radius: 10px; background: #FFFFFF; }
.act-tabla .tbl-datos { min-width: 520px; font-size: 12.5px; }
.act-tabla .tbl-datos thead th { background: var(--warn); font-size: 10.5px; }
.act-tabla .tbl-datos tbody th { position: static; min-width: 110px; }
.act-tabla .act-etq { display: inline-block; margin-bottom: 4px; }
.act-tabla .act-texto { display: block; }
.act-tabla .act-enlace { display: block; text-align: center; }

/* =====================================================================
   Flashcard v2: lienzo de 1080 px de ancho (4:5 o 9:16) mostrado a escala; diseño en bloques
   ===================================================================== */
.fc-medidas { margin-top: -6px; font-size: 11px; color: #E2E8F0; letter-spacing: .3px; }
.flashcard-render-wrap { width: 100%; }
.flashcard-tarjeta { position: relative; width: 100%; border-radius: 18px; overflow: hidden; background: #FFFFFF; box-shadow: 0 30px 60px -20px rgba(15, 23, 42, .45); }

.fc-lienzo { --fc-k: 1; --fc-alto: 1350px; position: absolute; left: 0; top: 0; width: 1080px; height: var(--fc-alto); transform-origin: 0 0; display: flex; flex-direction: column; background: var(--fc-bg); font-family: var(--f-cuerpo); color: #1E293B; overflow: hidden; }
.fc-lienzo > * { position: relative; z-index: 1; }
.fc-lienzo > .fc-marca-agua { display: none; }
.fc-cab { flex: none; box-sizing: border-box; height: 110px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 48px; background: var(--fc-pastel); }
.fc-logo { height: 66px; width: auto; flex: 0 0 auto; }
.fc-cab-txt { flex: 1; min-width: 0; display: flex; align-items: center; gap: 20px; }
.fc-kicker { display: none; }
.fc-pill { max-width: 100%; padding: 0; background: none; color: var(--fc-contraste); font: 700 22px var(--f-titulo); letter-spacing: .14em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-ia { flex: 0 0 auto; padding: 8px 18px; border-radius: 12px; background: #FFFFFF; color: var(--fc-contraste); font: 800 20px var(--f-titulo); letter-spacing: .04em; }
.fc-titulo { flex: none; margin: 0; padding: 34px 48px 0; font: 800 62px / 1.05 var(--f-titulo); color: var(--fc-contraste); letter-spacing: -.01em; }
.fc-cuerpo { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 20px; padding: 26px 48px 22px; }
.fc-fila { display: grid; grid-template-columns: 1fr; gap: 20px; }
.fc-fila.dos { grid-template-columns: 1fr 1fr; }
/* El espacio sobrante se reparte entre las tarjetas (centradas) para que la imagen no quede con un vacío al final; las tablas conservan su altura. */
.fc-cuerpo > .fc-fila { flex: 1 1 auto; }
.fc-flujo { display: flow-root; font-size: calc(30px * var(--fc-k)); }
.fc-flujo > .fc-bloque { display: block; padding: 0; margin: 0 0 calc(16px * var(--fc-k)); border: 0; border-radius: 0; background: none; }
.fc-flota { float: right; box-sizing: border-box; width: calc(340px + 80px * var(--fc-k)); margin: 0 0 calc(16px * var(--fc-k)) 30px; padding: calc(14px * var(--fc-k)); background: #FFFFFF; border: 1px solid #E2E8F0; border-bottom: 4px solid #E2E8F0; border-radius: 20px; }
.fc-flota img { display: block; margin: 0 auto; }
.fc-flota figcaption { margin-top: calc(8px * var(--fc-k)); font-size: calc(20px * var(--fc-k)); line-height: 1.3; color: #475569; opacity: 1; }
.fc-flujo .fc-bloque-tit { display: block; margin: 0 0 calc(6px * var(--fc-k)); font-size: calc(32px * var(--fc-k)); }
.fc-flujo .fc-bloque-tit i { display: inline-block; margin-right: 12px; vertical-align: 2px; }
.fc-flujo .fc-bloque.destacado { background: none; box-shadow: none; }
.fc-flujo .fc-bloque.destacado p { font: 700 calc(32px * var(--fc-k)) / 1.3 var(--f-titulo); color: var(--fc-contraste); }
.fc-flujo .fc-lista { display: block; }
.fc-flujo .fc-lista li { margin-bottom: calc(10px * var(--fc-k)); }
.fc-cuerpo > .fc-fila:has(.fcb-tabla) { flex: none; }
.fc-fila > .fc-bloque:not(.fcb-tabla) { display: flex; flex-direction: column; justify-content: center; }
.fc-lienzo.fc-medir { height: auto; }
.fc-bloque { min-width: 0; padding: calc(24px * var(--fc-k)) calc(28px * var(--fc-k)); border: 1px solid #E2E8F0; border-bottom: 4px solid #E2E8F0; border-radius: 20px; background: #FFFFFF; }
.fc-bloque-tit { display: flex; align-items: center; gap: 14px; margin: 0 0 calc(12px * var(--fc-k)); font: 700 calc(30px * var(--fc-k)) / 1.15 var(--f-titulo); color: var(--fc-contraste); }
.fc-bloque-tit i { flex: 0 0 auto; width: calc(20px * var(--fc-k)); height: calc(20px * var(--fc-k)); border-radius: 50%; background: var(--fc-pastel); border: 4px solid var(--fc-contraste); box-sizing: border-box; }
.fc-bloque p { margin: 0; font: 400 calc(30px * var(--fc-k)) / 1.45 var(--f-cuerpo); }
.fc-lista, .fc-pasos { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: calc(11px * var(--fc-k)); }
.fc-lista li { position: relative; padding-left: calc(36px * var(--fc-k)); font: 400 calc(29px * var(--fc-k)) / 1.4 var(--f-cuerpo); }
.fc-lista li::before { content: ''; position: absolute; left: 0; top: calc(11px * var(--fc-k)); width: calc(15px * var(--fc-k)); height: calc(15px * var(--fc-k)); border-radius: 50%; background: var(--fc-contraste); }
.fc-pasos li { display: flex; align-items: flex-start; gap: calc(18px * var(--fc-k)); font: 400 calc(29px * var(--fc-k)) / 1.4 var(--f-cuerpo); }
.fc-pasos li b { flex: 0 0 auto; display: grid; place-items: center; width: calc(44px * var(--fc-k)); height: calc(44px * var(--fc-k)); border-radius: 50%; background: var(--fc-pastel); color: var(--fc-contraste); font: 800 calc(24px * var(--fc-k)) var(--f-titulo); }
.fc-cifras { display: flex; flex-direction: column; gap: calc(10px * var(--fc-k)); }
.fc-cifra { display: flex; align-items: baseline; gap: calc(18px * var(--fc-k)); font: 400 calc(28px * var(--fc-k)) / 1.35 var(--f-cuerpo); }
.fc-cifra b { flex: 0 0 auto; padding: calc(2px * var(--fc-k)) calc(16px * var(--fc-k)) calc(4px * var(--fc-k)); border-radius: 12px; background: var(--fc-pastel); color: var(--fc-contraste); font-weight: 500; }
.fc-tabla { border-bottom: 4px solid #E2E8F0 !important; width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: calc(24px * var(--fc-k)); line-height: 1.3; overflow: hidden; border-radius: 20px; border: 1px solid #E2E8F0; background: #FFFFFF; }
.fc-tabla th, .fc-tabla td { padding: calc(11px * var(--fc-k)) calc(16px * var(--fc-k)); text-align: left; vertical-align: middle; border-bottom: 1px solid #E2E8F0; overflow-wrap: break-word; }
.fc-tabla thead th { background: var(--fc-pastel); color: var(--fc-contraste); font: 700 calc(17px * var(--fc-k)) var(--f-titulo); letter-spacing: .08em; text-transform: uppercase; }
.fc-lienzo .fc-tabla thead :is(th, td) { text-align: center !important; }
.fc-lienzo .fc-tabla tbody :is(th, td) { text-align: center !important; }
.fc-lienzo .fc-tabla tbody th:first-child, .fc-lienzo .fc-tabla tbody tr > :first-child { text-align: left !important; }
.fc-tabla tbody th { width: 24%; background: transparent; color: #1E293B; font-weight: 500; }
.fc-tabla tbody tr:nth-child(even) th, .fc-tabla tbody tr:nth-child(even) td { background: #F8FAFC; }
.fc-tabla tbody tr:last-child th, .fc-tabla tbody tr:last-child td { border-bottom: 0; }
.fc-bloque.fcb-tabla { padding: 0; border: 0; background: none; box-shadow: none; }
.fc-bloque.fcb-tabla .fc-bloque-tit { margin-bottom: 12px; font-size: calc(20px * var(--fc-k)); letter-spacing: .1em; text-transform: uppercase; }
.fc-pie { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 48px 26px; border-top: 1px solid #E2E8F0; background: transparent; }
.fc-pie-izq { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fc-firma { display: inline-flex; align-items: center; gap: 12px; font: 700 21px var(--f-titulo); color: var(--fc-contraste); }
.fc-firma img { display: none; }
.fc-aviso { font-size: 18px; color: #475569; }
.fc-origen { max-width: 52%; text-align: right; font-size: 19px; font-weight: 500; line-height: 1.25; color: #1E293B; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fc-origen b { display: inline-block; padding: 0 12px; margin-right: 8px; border-radius: 12px; background: var(--fc-pastel); color: var(--fc-contraste); font-weight: 500; }

/* Valoración de la respuesta */
.fb-fila { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--linea); font-size: 12px; color: var(--text-3); }
.fb-btn { display: inline-grid; place-items: center; width: 30px; height: 28px; border: 1px solid var(--linea); border-radius: 999px; background: var(--superficie); color: var(--text-2); cursor: pointer; padding: 0; }
.fb-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fb-btn:hover { border-color: var(--azul-borde); color: var(--azul); }
.fb-btn.activo { background: var(--azul-suave); border-color: var(--azul); color: var(--azul); }
.fb-link { border: 0; background: none; padding: 2px 4px; color: var(--azul); font: 500 12px var(--f-cuerpo); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.fb-gracias { color: var(--ok); font-weight: 500; }
.fb-form { margin-top: 8px; padding: 10px; border: 1px solid var(--linea); border-radius: 12px; background: var(--superficie-2); }
.fb-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.fb-cats label { cursor: pointer; }
.fb-cats input { position: absolute; opacity: 0; pointer-events: none; }
.fb-cats span { display: inline-block; padding: 4px 10px; border: 1px solid var(--linea); border-radius: 999px; background: var(--superficie); font-size: 12px; color: var(--text-2); }
.fb-cats input:checked + span { border-color: var(--azul); background: var(--azul-suave); color: var(--azul-oscuro); font-weight: 600; }
.fb-cats input:focus-visible + span { outline: 2px solid var(--azul); outline-offset: 2px; }
.fb-form textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--linea); border-radius: 10px; font: 13px var(--f-cuerpo); resize: vertical; }
.fb-acc { display: flex; gap: 8px; margin-top: 8px; }
.fb-enviar { border: 0; border-radius: 999px; padding: 7px 16px; background: var(--azul-oscuro); color: #fff; font: 500 12.5px var(--f-cuerpo); cursor: pointer; }
.fb-cancelar { border: 1px solid var(--linea); border-radius: 999px; padding: 7px 14px; background: var(--superficie); color: var(--text-2); font: 500 12.5px var(--f-cuerpo); cursor: pointer; }

/* Botones de solo ícono en la barra y estado de descarga */
.pro-btn.generando svg { animation: pulso-descarga .8s ease-in-out infinite; }
@keyframes pulso-descarga { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .pro-btn.generando svg { animation: none; opacity: .5; } }

/* Puentes hacia Exámenes y Ultraresúmenes */
.acciones-chat { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.accion-chat { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; border: 1px solid var(--azul-borde); border-radius: 14px; background: var(--azul-suave); color: var(--azul-oscuro); text-align: left; cursor: pointer; font-family: var(--f-cuerpo); }
.accion-chat:hover { border-color: var(--azul); background: #E4EEFF; }
.accion-ico { flex: 0 0 auto; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--azul-oscuro); color: #fff; }
.accion-ico svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.accion-ultra .accion-ico { background: var(--gineco-contraste, #9D174D); }
.accion-txt { display: flex; flex-direction: column; min-width: 0; }
.accion-txt b { font-size: 13.5px; }
.accion-txt small { font-size: 11.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sugerencia-estudio { margin-top: 12px; padding: 12px; border: 1px dashed var(--azul-borde); border-radius: 14px; background: #FAFCFF; }
.sugerencia-estudio p { margin: 4px 0 10px; font-size: 13px; color: var(--text-2); }
.sugerencia-tag { font: 600 9.5px var(--f-cuerpo); letter-spacing: .6px; text-transform: uppercase; color: var(--azul); }

.fc-bloque.destacado { background: var(--fc-contraste); border-color: var(--fc-contraste); box-shadow: none; }
.fc-bloque.destacado .fc-bloque-tit { color: rgba(255, 255, 255, .85); font-size: calc(20px * var(--fc-k)); letter-spacing: .12em; text-transform: uppercase; }
.fc-bloque.destacado .fc-bloque-tit i { background: #FFFFFF; border-color: #FFFFFF; }
.fc-bloque.destacado p { font: 700 calc(30px * var(--fc-k)) / 1.3 var(--f-titulo); color: #FFFFFF; }
.fc-nota { margin: 14px 4px 0; font-size: calc(22px * var(--fc-k)); line-height: 1.4; color: #64748B; }
.fc-paginas { display: flex; align-items: center; justify-content: center; gap: 14px; color: #F1F5F9; font: 500 13px var(--f-cuerpo); }
.fc-pag-btn { width: 34px; height: 34px; border: 0; border-radius: 50%; background: rgba(255,255,255,.92); color: var(--azul-oscuro); font-size: 20px; line-height: 1; cursor: pointer; }
.fc-pag-btn:disabled { opacity: .4; cursor: default; }
#btn-descargar-todas { margin-top: 8px; }

/* El árbol (y sus tablas) siempre centrados: en el chat, en pantalla completa y en la imagen exportada */
.alg-lienzo { margin-left: auto; margin-right: auto; }
.alg-comp-fila { justify-content: center; }
.alg-fs-fig .alg-comp-fila { width: 0; min-width: 100%; box-sizing: border-box; }

/* Flashcard: el algoritmo conserva su formato de árbol */
.fc-bloque.fcb-algoritmo { padding: 22px; }
.fc-alg-marco { width: 100%; overflow: hidden; }
.fc-alg-esc { margin: 0 auto; }
.fc-alg-lienzo { margin: 0 !important; transform-origin: top left; }
.reg-ayuda-password { margin: -6px 0 8px; font-size: 11px; color: var(--ui-grey, #667085); }
.login-recordar { margin-top: 8px; }

/* Navegación visible y pista independiente: no se comprime en pantallas bajas. */
.chat-sugerencias { flex: 0 0 auto; min-width: 0; max-width: 100%; align-items: center; overflow: visible; scroll-snap-type: none; }
.chat-sugerencias-pista { display: flex; flex: 1 1 auto; min-width: 0; gap: 10px; overflow-x: auto; padding: 3px 2px 6px; scrollbar-width: thin; overscroll-behavior-x: contain; }
.chat-sugerencias .chat-sugerencias-nav { flex: 0 0 34px; min-width: 34px; width: 34px; height: 34px; padding: 0; font-size: 24px; box-shadow: none; }
.chat-sugerencias-nav:disabled { opacity: .35; cursor: default; }
.chat-sugerencias button:focus-visible, .chat-sugerencias-pista:focus-visible { outline: 2px solid var(--azul); outline-offset: -2px; }

/* =====================================================================
   Login editorial · panel de marca Dr. Notes
   ===================================================================== */
.login-overlay { background: radial-gradient(900px 520px at 12% 0%, var(--azul-suave), transparent 70%), var(--bg-paper); }
@media (min-width: 901px) { .login-escena { width: min(100%, 1040px); grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); } }
.login-escena { border-radius: 28px; box-shadow: 0 40px 80px -48px rgba(30, 58, 95, .55), var(--sombra-suave); }
.login-marca-panel {
    position: relative; overflow: hidden; gap: 0; padding: 44px 46px 34px; border-right: 0; color: #fff;
    background: radial-gradient(120% 90% at 100% 0%, rgba(37, 99, 235, .38), transparent 60%), linear-gradient(160deg, var(--azul-oscuro) 0%, #16304F 100%);
}
.login-marca-panel::after { content: ''; position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1px); background-size: 22px 22px; -webkit-mask-image: linear-gradient(200deg, #000, transparent 65%); mask-image: linear-gradient(200deg, #000, transparent 65%); }
.login-marca-panel > * { position: relative; z-index: 1; }
.login-marca-cab { margin-bottom: 34px; }
.login-marca-cab img { height: 42px; padding: 5px 7px; border-radius: 12px; background: #fff; box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .5); }
.login-marca-cab span { color: #fff; font-size: 15px; }
.login-marca-eyebrow { font: 600 11px var(--f-cuerpo); letter-spacing: .18em; text-transform: uppercase; color: rgba(255, 255, 255, .66); }
.login-marca-panel h2 { margin: 10px 0 12px; max-width: 420px; color: #fff; font-size: 29px; line-height: 1.18; }
.login-marca-panel > p { max-width: 410px; color: rgba(255, 255, 255, .8); font-size: 14.5px; }
.login-ruta { list-style: none; margin: 28px 0 0; padding: 0; display: grid; gap: 0; }
.login-ruta li { position: relative; display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 14px; padding: 0 0 18px; }
.login-ruta li:not(:last-child)::before { content: ''; position: absolute; left: 20px; top: 44px; bottom: 2px; width: 1px; background: linear-gradient(rgba(255,255,255,.28), rgba(255,255,255,.06)); }
.login-ruta-ico { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16); }
.login-ruta-ico svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.login-ruta li:first-child .login-ruta-ico { background: rgba(16, 185, 129, .16); border-color: rgba(16, 185, 129, .45); }
.login-ruta li:first-child .login-ruta-ico svg { stroke: var(--ok-solido); }
.login-ruta small { display: block; font: 600 10.5px var(--f-cuerpo); letter-spacing: .14em; text-transform: uppercase; color: rgba(255, 255, 255, .55); }
.login-ruta b { display: block; margin-top: 1px; font: 600 14.5px var(--f-titulo); color: #fff; }
.login-ruta div > span { display: block; margin-top: 2px; font-size: 13px; line-height: 1.45; color: rgba(255, 255, 255, .72); }
.login-marca-panel .login-marca-pie { color: rgba(255, 255, 255, .5) !important; }

.login-card { padding: 48px 46px 34px; }
.login-brand { margin-bottom: 26px; }
.login-copy { margin-bottom: 18px; }
.login-copy h1 { font-size: 28px; }
.login-card label { margin-top: 8px; font-weight: 600; color: var(--text-main); }
.login-input-wrap input, .login-input-wrap select { min-height: 48px; border-radius: 12px; background: var(--superficie-2); border-color: var(--linea); transition: border-color .2s, box-shadow .2s, background .2s; }
.login-input-wrap input:hover, .login-input-wrap select:hover { border-color: var(--azul-borde); }
.login-input-wrap input:focus, .login-input-wrap select:focus { background: var(--superficie); }
.login-input-wrap:focus-within > svg { stroke: var(--azul); }
.login-card .btn-login { min-height: 50px; border-radius: 12px; font-size: 15px; }
.login-2fa { padding: 14px; border: 1px solid var(--azul-borde); border-radius: 14px; background: var(--azul-suave); }
.login-seguridad { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--linea); }

@media (max-width: 900px) {
    .login-overlay .login-escena .login-card { grid-column: 1; }
    .login-card { padding: 34px 26px 26px; }
    .login-copy h1 { font-size: 25px; }
}
@media (max-width: 560px) {
    .login-overlay .login-escena { border-top: 4px solid var(--azul-oscuro); }
    .login-card { padding-top: 26px; }
}


/* Fecha y hora del mensaje (al pasar el cursor, enfocar o tocar) */
.msg { position: relative; }
.msg-hora {
    position: absolute;
    top: calc(100% + 3px);
    font: 500 11.5px/1.3 var(--f-cuerpo);
    color: var(--text-3);
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-3px);
    transition: opacity .16s ease, transform .16s ease;
    pointer-events: none;
}
.msg-user .msg-hora { right: 6px; }
.msg-bot .msg-hora { left: 54px; }
.msg:hover .msg-hora,
.msg:focus-within .msg-hora,
.msg.ver-hora .msg-hora { opacity: 1; transform: none; }

/* ---------- Sello de GPC: clave en cápsula + nombre de la guía en letra pequeña ---------- */
.gpc-sello { display: inline-flex; flex-direction: column; gap: 3px; min-width: 0; max-width: 100%; vertical-align: top; }
.gpc-fila { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gpc-cod { display: inline-block; padding: 1px 9px; border-radius: 999px; background: var(--azul-suave); border: 1px solid var(--azul-borde); color: var(--azul-oscuro);
    font: 600 10.5px/1.55 var(--f-cuerpo); letter-spacing: .04em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gpc-tipo { font: 600 9.5px/1.55 var(--f-cuerpo); font-style: normal; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); padding-left: 6px; border-left: 1px solid var(--linea); }
.gpc-nom { font: 400 11.5px/1.42 var(--f-cuerpo); color: var(--text-3); text-wrap: pretty; }
.gpc-sello-compacto .gpc-nom { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fuente-contenido .gpc-sello { gap: 4px; }


/* Respuesta con fuentes externas (búsqueda avanzada cuando la GPC no cubre la pregunta) */
.ext-cab { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 10px; padding: 8px 12px; border-radius: 12px; background: var(--warn-bg, #FFFBEB); border: 1px solid var(--warn-borde, #FDE68A); color: var(--warn, #92400E); font-size: 12.5px; line-height: 1.45; }
.ext-cab b { font-weight: 700; letter-spacing: .02em; }
.ext-fuentes { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--linea-suave, var(--linea)); display: grid; gap: 6px; }
.ext-fuentes-t { font: 600 11px var(--f-cuerpo); letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.ext-fuente { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; font-size: 13px; }
.ext-fuente .n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 7px; background: var(--azul-suave); color: var(--azul-oscuro); font: 600 11px var(--f-cuerpo); }
.ext-fuente .t { min-width: 0; display: grid; gap: 1px; overflow-wrap: anywhere; }
.ext-fuente a { color: var(--azul); text-decoration: none; font-weight: 500; }
.ext-fuente a:hover { text-decoration: underline; }
.ext-fuente small { color: var(--text-3); font-size: 11.5px; }

/* =====================================================================
   Navegación principal · 5 secciones (ChatGPC, Exámenes, Ultrarresúmenes, Simulador, Mi progreso)
   Las pestañas toman solo el espacio libre entre la marca y las acciones: nunca se enciman.
   ===================================================================== */
@media (min-width: 721px) {
    .app-header { grid-template-columns: auto minmax(0, 1fr) auto; }
    .tabs-app { min-width: 0; max-width: 100%; overflow-x: auto; scrollbar-width: none; justify-self: center; }
    .tabs-app::-webkit-scrollbar { display: none; }
    .tab-app { flex: 0 0 auto; }
    .header-acciones { flex-wrap: nowrap; }
    .btn-logout-chat { white-space: nowrap; }
}
@media (max-width: 1640px) and (min-width: 721px) {
    .brand-textos p { display: none; }
    #btn-logout span { display: none; }
    #btn-logout { padding: 8px; }
}
@media (max-width: 1440px) and (min-width: 721px) {
    .app-header { gap: 12px; padding: 10px 18px; }
    .tab-app { padding: 8px 12px; gap: 6px; font-size: 13px; }
    .tab-app .largo { display: none; }
    .tab-app .corto { display: inline; }
    .btn-historial span { display: none; }
    .btn-historial { padding: 8px; }
}
@media (max-width: 1240px) and (min-width: 721px) {
    .header-acciones .cuenta-chip { min-width: 45px; width: 45px; justify-content: center; padding: 5px; }
    .header-acciones .cuenta-chip-copy { width: 7px; overflow: hidden; }
    .header-acciones .cuenta-chip-copy b, .header-acciones .cuenta-chip-copy small { display: none; }
    .header-acciones .cuenta-chip-copy i { margin: 0; }
    .tab-app { padding: 8px 11px; }
}
/* Tableta: la barra de secciones baja a su propia fila, a todo lo ancho */
@media (max-width: 1080px) and (min-width: 721px) {
    .app-header { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "marca acciones" "tabs tabs"; row-gap: 8px; padding: 10px 18px 8px; }
    .app-header > .brand { grid-area: marca; }
    .app-header > .header-acciones { grid-area: acciones; }
    .tabs-app { grid-area: tabs; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; border-radius: 14px; justify-self: stretch; }
    .tab-app { justify-content: center; border-radius: 11px; padding: 8px 6px; min-width: 0; }
    .tab-app > span:not(.tab-pro):not(.tab-lock) { overflow: hidden; text-overflow: ellipsis; }
}
/* Móvil: barra inferior con las 5 secciones en una sola fila */
@media (max-width: 720px) {
    .tabs-app { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; padding-left: 4px; padding-right: 4px; }
    .tab-app { min-width: 0; padding: 4px 2px; font-size: 10.5px; letter-spacing: -.1px; }
    .tab-app > span:not(.tab-pro):not(.tab-lock) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
    .tab-progreso .tab-pro { right: calc(50% - 24px); }
    .tab-app .tab-lock { position: absolute; top: 3px; left: calc(50% + 8px); }
    .tab-app { position: relative; }
}
@media (max-width: 360px) {
    .tab-app { font-size: 9.5px; }
    .tab-app svg { width: 19px; height: 19px; }
}

/* Copiar respuesta + farmacología de la búsqueda avanzada */
.msg-acciones-fila { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.msg-acciones-fila .btn-flashcard-mini { margin-top: 0; }
@media (max-width: 640px) { .msg-acciones-fila .btn-flashcard-mini { flex: 1 1 auto; } }
.btn-copiar-icono { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; flex: none; border: 1px solid var(--azul-borde); border-radius: 10px; background: #fff; color: var(--azul-oscuro); cursor: pointer; transition: background .15s, color .15s; }
.btn-copiar-icono svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn-copiar-icono:hover { background: var(--azul-suave); }
.btn-copiar-icono:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; }
.btn-copiar-icono.copiado { background: var(--ok-bg); border-color: var(--ok-borde); color: var(--ok); }
.btn-copiar-icono.error { background: var(--bad-bg); border-color: var(--bad-borde, var(--bad)); color: var(--bad); }
/* Mensajes del usuario: el ícono aparece junto a la burbuja al pasar el cursor o enfocar; en pantallas táctiles siempre visible */
.msg-user { align-items: center; gap: 6px; }
.btn-copiar-user { width: 30px; height: 30px; border-color: transparent; background: transparent; opacity: 0; transition: opacity .15s, background .15s; }
.msg-user:hover .btn-copiar-user, .btn-copiar-user:focus-visible, .btn-copiar-user.copiado, .btn-copiar-user.error { opacity: 1; }
@media (hover: none) { .btn-copiar-user { opacity: .75; } }
@media (max-width: 640px) { .msg-acciones-fila .btn-flashcard-mini { flex: 1 1 100%; } }
.act-sub { margin: 12px 0 6px; font: 600 12px var(--f-titulo); letter-spacing: .3px; color: var(--warn); }
.act-farmaco { padding: 10px 12px; border: 1px solid var(--azul-borde); border-radius: 12px; background: var(--azul-suave); display: grid; gap: 6px; }
.act-farmaco-t { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.act-farmaco-t svg { width: 18px; height: 18px; fill: none; stroke: var(--azul); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.act-farmaco-t b { font: 700 12px var(--f-titulo); text-transform: uppercase; letter-spacing: .5px; color: var(--azul-oscuro); }
.act-farmaco-txt { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text-main); }
.act-farmaco-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.act-farmaco-meta.sin-fuente { color: var(--text-3); font-style: italic; }

/* Citas y fuentes navegables */
.msg-bubble b.gpc-cita[data-n] { cursor: pointer; transition: background .15s, color .15s; }
.msg-bubble b.gpc-cita[data-n]:hover, .msg-bubble b.gpc-cita[data-n]:focus-visible { background: var(--azul-borde); outline: none; }
.fuente-item { align-items: center; }
.fuente-item .fuente-contenido { flex: 1; min-width: 0; }
.fuente-abrir { flex: none; border: 1px solid var(--azul-borde); background: var(--superficie); color: var(--azul); border-radius: 999px; padding: 4px 11px; font: 500 12px var(--f-cuerpo); cursor: pointer; transition: background .15s, border-color .15s; }
.fuente-abrir:hover, .fuente-abrir:focus-visible { background: var(--azul-suave); border-color: var(--azul); outline: none; }
.fuente-item.fuente-resaltada { animation: fuente-resalte 1.6s ease-out; }
@keyframes fuente-resalte { 0% { box-shadow: 0 0 0 3px var(--azul-borde); } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (max-width: 560px) { .fuente-item { flex-wrap: wrap; } .fuente-abrir { margin-left: 34px; } }
@media (prefers-reduced-motion: reduce) { .fuente-item.fuente-resaltada { animation: none; outline: 2px solid var(--azul-borde); } }

/* Móvil: «Cerrar sesión» separado del historial */
@media (max-width: 720px) { #btn-logout { margin-left: 10px; } }
