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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f0f0;
    color: #222;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#chat-container {
    width: 100%;
    max-width: 600px;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
}

@media (min-width: 640px) {
    #chat-container {
        height: 90vh;
        border-radius: 16px;
        box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    }
}

#chat-header {
    padding: 20px 20px 16px;
    background: #ffffff;
    text-align: center;
    border-bottom: 1px solid #ccc;
    flex-shrink: 0;
}

#chat-header h1 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #222;
    margin: 6px 0 2px 0;
}

#chat-header p {
    font-size: 12px;
    color: #999;
    margin-top: 3px;
}

#mensajes {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #e8e8e8;
    -webkit-overflow-scrolling: touch;
}

.mensaje-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.mensaje {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.mensaje.usuario {
    background: #444;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.mensaje.asistente {
    background: #fff;
    color: #222;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.mensaje.cargando {
    background: #fff;
    align-self: flex-start;
    color: #bbb;
    font-style: italic;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

#input-container {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: #fff;
    display: flex;
    gap: 8px;
    border-top: 1px solid #f0e0e5;
    flex-shrink: 0;
}

#input-texto {
    flex: 1;
    background: #faf8f8;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px 14px;
    color: #222;
    font-size: 16px;
    outline: none;
    resize: none;
    height: 44px;
    max-height: 120px;
    overflow-y: auto;
    font-family: inherit;
}

#input-texto:focus {
    border-color: #111;
}

#btn-enviar {
    background: #111;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    min-width: 70px;
    height: 44px;
    flex-shrink: 0;
}

#btn-enviar:hover { opacity: 0.85; }
#btn-enviar:disabled { opacity: 0.3; cursor: not-allowed; }

@keyframes brillo {
    0% { background-position: 200% center; }
    100% { background-position: -200% center; }
}