:root {
    --fondo: #fff3de;
    --fondo-suave: #fff9ef;
    --panel: #ffffff;
    --sidebar: #ffe6b8;

    --principal: #ffd076;
    --principal-hover: #f4bd52;

    --borde: #efd29b;
    --texto: #2d2d2d;
    --texto-suave: #777067;

    --sombra: 0 12px 30px rgba(121, 78, 24, 0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
}

body {
    overflow: hidden;
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--texto);
    background: var(--fondo);
}

button,
input,
select {
    font: inherit;
}

/* ==============================
   Pantalla de bienvenida
============================== */

.welcome-screen {
    position: fixed;
    inset: 0;
    z-index: 100;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    background:
        radial-gradient(
            circle at top left,
            rgba(255, 208, 118, 0.5),
            transparent 38%
        ),
        linear-gradient(135deg, #fff8eb, #ffe7ba);
}

.welcome-card {
    width: min(440px, 100%);

    display: flex;
    flex-direction: column;
    gap: 12px;

    padding: 34px;

    background: var(--panel);
    border: 1px solid var(--borde);
    border-radius: 28px;
    box-shadow: var(--sombra);
}

.welcome-logo {
    width: 120px;
    margin: 0 auto 4px;
}

.welcome-card h1 {
    text-align: center;
    font-size: 29px;
}

.welcome-card p {
    margin-bottom: 6px;
    text-align: center;
    color: var(--texto-suave);
    line-height: 1.5;
}

.welcome-card label {
    margin-top: 4px;
    font-size: 14px;
    font-weight: 700;
}

.welcome-card input,
.welcome-card select {
    width: 100%;
    padding: 14px 15px;

    color: var(--texto);
    background: var(--fondo-suave);

    border: 1px solid var(--borde);
    border-radius: 14px;
    outline: none;
}

.welcome-card input:focus,
.welcome-card select:focus {
    border-color: var(--principal-hover);
    box-shadow: 0 0 0 3px rgba(255, 208, 118, 0.28);
}

.welcome-card button {
    margin-top: 10px;
    padding: 15px;

    color: var(--texto);
    background: var(--principal);

    border: none;
    border-radius: 15px;

    font-weight: 800;
    cursor: pointer;
}

.welcome-card button:hover {
    background: var(--principal-hover);
}

/* ==============================
   Aplicación
============================== */

.app {
    width: 100%;
    height: 100vh;

    display: flex;
    flex-direction: column;
}

/* Cabecera */

.app-header {
    height: 74px;
    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 28px;

    background: var(--panel);
    border-bottom: 1px solid var(--borde);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand img {
    width: 54px;
    height: 46px;
    object-fit: contain;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 21px;
}

.brand small {
    margin-top: 2px;
    color: var(--texto-suave);
}

.user-area {
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 700;
}

/* Distribución principal */

.app-layout {
    flex: 1;
    min-height: 0;

    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
}

/* Barra lateral */

.sidebar {
    min-height: 0;
    padding: 24px;

    overflow-y: auto;

    background: var(--sidebar);
    border-right: 1px solid var(--borde);
}

.sidebar h2 {
    margin-bottom: 16px;
    color: #795b2c;
    font-size: 16px;
}

.new-class-btn {
    width: 100%;
    padding: 14px;

    color: #765000;
    background: var(--panel);

    border: none;
    border-radius: 15px;

    font-weight: 800;
    cursor: pointer;

    transition: transform 0.2s, box-shadow 0.2s;
}

.new-class-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--sombra);
}

.class-list {
    margin-top: 18px;
}

/* Zona principal */

.classroom {
    min-width: 0;
    min-height: 0;

    display: flex;
    flex-direction: column;

    background: var(--fondo);
}

/* Profesor */

.teacher-header {
    flex-shrink: 0;

    display: flex;
    align-items: center;
    gap: 17px;

    margin: 24px 36px 16px;
    padding: 18px 22px;

    background: var(--panel);
    border: 1px solid var(--borde);
    border-radius: 22px;
    box-shadow: var(--sombra);
}

.teacher-header img {
    width: 68px;
    height: 58px;
    object-fit: contain;
}

.teacher-header h1 {
    font-size: 26px;
}

.teacher-header p {
    margin-top: 3px;
    color: var(--texto-suave);
}

/* ==============================
   Conversación
============================== */

.messages {
    flex: 1;
    min-height: 0;

    margin: 0 36px;
    padding: 22px;

    overflow-y: auto;
    overflow-x: hidden;

    background: var(--panel);
    border: 1px solid var(--borde);
    border-radius: 24px;

    scroll-behavior: smooth;
}

/* Estilo compartido de mensajes */

.user,
.ia {
    width: fit-content;
    max-width: 78%;

    margin-bottom: 18px;
    padding: 15px 18px;

    border-radius: 18px;

    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Mensaje del usuario */

.user {
    max-width: min(520px, 75%);
    margin-left: auto;

    color: var(--texto);
    background: var(--principal);

    font-weight: 600;
}

/* Respuesta de la IA */

.ia {
    width: min(820px, 82%);
    max-height: 330px;

    margin-right: auto;

    overflow-y: auto;
    overflow-x: hidden;

    color: var(--texto);
    background: var(--fondo-suave);

    border: 1px solid var(--borde);
    scrollbar-width: thin;
    scrollbar-color: var(--principal-hover) transparent;
}

/* Barra interna de respuestas largas */

.ia::-webkit-scrollbar {
    width: 8px;
}

.ia::-webkit-scrollbar-track {
    background: transparent;
}

.ia::-webkit-scrollbar-thumb {
    background: var(--principal);
    border-radius: 999px;
}

.ia::-webkit-scrollbar-thumb:hover {
    background: var(--principal-hover);
}

/* ==============================
   Campo de escritura
============================== */

.composer {
    flex-shrink: 0;

    display: flex;
    gap: 12px;

    margin: 16px 36px 24px;
    padding: 11px;

    background: var(--panel);
    border: 1px solid var(--borde);
    border-radius: 22px;
    box-shadow: var(--sombra);
}

.composer input {
    flex: 1;
    min-width: 0;

    padding: 13px;

    color: var(--texto);
    background: transparent;

    border: none;
    outline: none;

    font-size: 16px;
}

.composer input::placeholder {
    color: #9a9186;
}

.composer button {
    width: 50px;
    height: 50px;
    flex-shrink: 0;

    color: var(--texto);
    background: var(--principal);

    border: none;
    border-radius: 16px;

    font-size: 20px;
    font-weight: 900;

    cursor: pointer;
}

.composer button:hover {
    background: var(--principal-hover);
}

.composer button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==============================
   Diseño adaptable
============================== */

@media (max-width: 800px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .app-header {
        padding: 0 18px;
    }

    .brand small {
        display: none;
    }

    .teacher-header {
        margin: 16px 18px 12px;
        padding: 14px 17px;
    }

    .teacher-header img {
        width: 55px;
        height: 48px;
    }

    .teacher-header h1 {
        font-size: 21px;
    }

    .messages {
        margin: 0 18px;
        padding: 16px;
    }

    .composer {
        margin: 13px 18px 17px;
    }

    .user,
    .ia {
        max-width: 92%;
    }

    .ia {
        width: 92%;
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .welcome-card {
        padding: 25px 20px;
    }

    .welcome-card h1 {
        font-size: 24px;
    }

    .user-area {
        font-size: 14px;
    }

    .teacher-header p {
        font-size: 14px;
    }

    .ia {
        max-height: 260px;
    }
}