:root {
            --bg-dark: #070a13;
            --bg-card: rgba(17, 24, 39, 0.6);
            --bg-glass: rgba(255, 255, 255, 0.03);
            --border-glass: rgba(255, 255, 255, 0.08);
            --text-primary: #f3f4f6;
            --text-secondary: #9ca3af;
            --coral-primary: #e06666;
            --coral-hover: #f28b82;
            --cyan-accent: #4deeea;
            --user-bubble: linear-gradient(135deg, #e06666 0%, #d05555 100%);
            --assistant-bubble: rgba(255, 255, 255, 0.04);
            --font-family: 'Outfit', sans-serif;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: var(--font-family);
            scrollbar-width: thin;
            scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
        }

        ::-webkit-scrollbar { width: 6px; height: 6px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 4px; }
        ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.25); }

        body {
            background-color: var(--bg-dark);
            background-image: 
                radial-gradient(at 0% 0%, rgba(224, 102, 102, 0.08) 0px, transparent 50%),
                radial-gradient(at 100% 100%, rgba(77, 238, 234, 0.05) 0px, transparent 50%),
                radial-gradient(at 50% 50%, rgba(17, 24, 39, 0.5) 0px, transparent 100%);
            color: var(--text-primary);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow-x: hidden;
        }

        .app-container {
            width: 92vw;
            height: 90vh;
            max-width: 1280px;
            display: grid;
            grid-template-columns: 320px minmax(0, 1fr);
            grid-template-rows: minmax(0, 1fr); 
            gap: 1.5rem;
            background: var(--bg-card);
            border: 1px solid var(--border-glass);
            border-radius: 24px;
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
            overflow: hidden;
            transition: all 0.3s ease;
        }

        /* Sidebar Styling */
        .sidebar {
            background: rgba(10, 15, 30, 0.4);
            border-right: 1px solid var(--border-glass);
            display: flex;
            flex-direction: column;
            position: relative;
            min-height: 0;
        }

        .sidebar-header {
            padding: 1.75rem 1.75rem 0.5rem 1.75rem;
            flex-shrink: 0;
        }

        .brand {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            margin-bottom: 1.5rem;
        }

        .brand-logo {
            width: 42px;
            height: 42px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: rgba(224, 102, 102, 0.1);
            border: 1px solid rgba(224, 102, 102, 0.3);
            border-radius: 12px;
            animation: pulse-border 3s infinite ease-in-out;
        }

        .brand-logo svg {
            width: 24px;
            height: 24px;
            fill: var(--coral-primary);
        }

        .brand-info h1 {
            font-size: 1.5rem;
            font-weight: 700;
            letter-spacing: -0.02em;
            background: linear-gradient(90deg, #ffffff 0%, #ffdfdf 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            text-shadow: 0 0 20px rgba(224, 102, 102, 0.3);
        }

        .brand-info span {
            font-size: 0.7rem;
            color: var(--cyan-accent);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            display: block;
            margin-top: 0.1rem;
            font-weight: 500;
            opacity: 0.9;
        }

        .traits-container {
            flex: 1;
            overflow-y: auto;
            padding: 0 1.75rem;
            min-height: 0;
        }

        .section-title {
            font-size: 0.8rem;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            color: var(--text-secondary);
            margin-bottom: 1rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding-top: 1rem;
        }

        .trait-badge {
            background: rgba(255, 255, 255, 0.05);
            color: var(--cyan-accent);
            padding: 0.2rem 0.5rem;
            border-radius: 10px;
            font-size: 0.7rem;
            font-weight: 700;
        }

        .traits-list {
            list-style: none;
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
            padding-bottom: 1rem;
        }

        .analysis-actions {
            display: grid;
            gap: 0.5rem;
        }

        .analysis-actions--sidebar {
            margin-bottom: 0.25rem;
        }

        .analysis-actions .trait-item {
            width: 100%;
            font: inherit;
            text-align: left;
        }

        .trait-item {
            padding: 0.7rem 0.9rem;
            border-radius: 12px;
            background: rgba(255, 255, 255, 0.01);
            border: 1px solid transparent;
            cursor: pointer;
            font-size: 0.875rem;
            color: var(--text-primary);
            transition: all 0.2s ease;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.5rem;
        }

        .trait-item:hover {
            background: rgba(255, 255, 255, 0.04);
            border-color: rgba(224, 102, 102, 0.2);
            color: var(--coral-primary);
            transform: translateX(3px);
        }

        .trait-item svg {
            width: 14px;
            height: 14px;
            opacity: 0;
            transition: all 0.2s ease;
            fill: currentColor;
        }

        .trait-item:hover svg {
            opacity: 1;
        }

        /* Bitgenia Branding Footer */
        .sidebar-footer {
            padding: 1.25rem 1.75rem;
            border-top: 1px solid var(--border-glass);
            background: rgba(0, 0, 0, 0.2);
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
        }

        .powered-by {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-size: 0.75rem;
            color: var(--text-secondary);
        }

        .bitgenia-logo-mini {
            width: 18px;
            height: 18px;
            fill: var(--text-primary);
            opacity: 0.8;
        }

        .powered-by strong {
            color: var(--text-primary);
            font-weight: 600;
            letter-spacing: 0.05em;
        }

        .agent-version {
            font-size: 0.65rem;
            color: var(--text-secondary);
            opacity: 0.5;
            letter-spacing: 0.05em;
            font-weight: 500;
        }

        /* --- CHAT AREA CON FLEXBOX --- */
        .chat-area {
            display: flex;
            flex-direction: column;
            height: 100%;
            background: rgba(0, 0, 0, 0.15);
            min-height: 0; 
        }

        .chat-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 2rem;
            height: 75px;
            flex-shrink: 0; 
            border-bottom: 1px solid var(--border-glass);
            background: rgba(10, 15, 30, 0.2);
        }

        .chat-status {
            display: flex;
            align-items: center;
            gap: 1rem;
        }

        .status-dot {
            width: 8px;
            height: 8px;
            background-color: var(--cyan-accent);
            border-radius: 50%;
            box-shadow: 0 0 10px var(--cyan-accent);
            animation: pulse-glow 2s infinite ease-in-out;
        }

        .chat-status-text h2 {
            font-size: 1.1rem;
            font-weight: 600;
            display: flex;
            align-items: center;
            gap: 0.4rem;
        }

        .chat-status-text h2 span {
            font-size: 0.85rem;
            font-weight: 300;
            color: var(--text-secondary);
        }

        .chat-status-text p {
            font-size: 0.75rem;
            color: var(--text-secondary);
            margin-top: 0.1rem;
        }

        /* Clear Chat Button */
        .clear-btn {
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid var(--border-glass);
            border-radius: 10px;
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: var(--text-secondary);
            transition: all 0.3s ease;
            outline: none;
        }

        .clear-btn:hover {
            background: rgba(224, 102, 102, 0.15);
            border-color: rgba(224, 102, 102, 0.3);
            color: var(--coral-hover);
            transform: rotate(180deg);
        }

        .clear-btn svg {
            width: 16px;
            height: 16px;
            fill: currentColor;
        }

        .feedback-open-btn:hover {
            transform: none;
        }

        /* Messages Box - Scroll interno */
        .messages-box {
            flex: 1; 
            min-height: 0; /* Crucial para flex interno */
            padding: 2rem;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 1.5rem;
        }

        .message-row { display: flex; width: 100%; }
        .message-row.user { justify-content: flex-end; }
        .message-row.assistant { justify-content: flex-start; }
        
        .message-wrapper {
            display: flex;
            gap: 0.85rem;
            max-width: 80%;
        }

        .message-row.user .message-wrapper { flex-direction: row-reverse; }

        .avatar {
            width: 38px;
            height: 38px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.15rem;
            flex-shrink: 0;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
        }

        .avatar.assistant {
            background: rgba(224, 102, 102, 0.15);
            border: 1px solid rgba(224, 102, 102, 0.3);
        }

        .avatar.user {
            background: rgba(255, 255, 255, 0.08);
            border: 1px solid rgba(255, 255, 255, 0.15);
        }

        .message-content {
            display: flex;
            flex-direction: column;
            gap: 0.35rem;
            min-width: 0;
        }

        .sender-name {
            font-size: 0.75rem;
            font-weight: 600;
            color: var(--text-secondary);
            margin-left: 0.25rem;
        }

        .message-row.user .sender-name {
            text-align: right;
            margin-right: 0.25rem;
            margin-left: 0;
        }

        .bubble {
            padding: 1.1rem 1.25rem;
            border-radius: 18px;
            font-size: 0.95rem;
            line-height: 1.6;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
            min-width: 0;
            overflow-wrap: anywhere;
            word-break: break-word;
        }

        .message-row.user .bubble {
            background: var(--user-bubble);
            border-top-right-radius: 4px;
            color: #ffffff;
        }

        .message-row.assistant .bubble {
            background: var(--assistant-bubble);
            border: 1px solid var(--border-glass);
            border-top-left-radius: 4px;
            color: var(--text-primary);
        }

        /* Bubble Formatting */
        .bubble strong { font-weight: 600; color: #ffffff; }
        .message-row.assistant .bubble strong { color: var(--coral-hover); }
        .bubble ul, .bubble ol { margin-left: 1.25rem; margin-top: 0.5rem; margin-bottom: 0.5rem; }
        .bubble li { margin-bottom: 0.35rem; }
        .bubble li::marker { color: var(--coral-primary); }
        .bubble p { margin-bottom: 0.75rem; }
        .bubble p:last-child { margin-bottom: 0; }
        .scientific-detail-action {
            display: inline-flex;
            align-items: center;
            min-height: 36px;
            margin-top: 14px;
            padding: 7px 12px;
            border: 1px solid rgba(224, 102, 102, 0.55);
            border-radius: 6px;
            background: rgba(224, 102, 102, 0.13);
            color: var(--coral-hover);
            font: inherit;
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
        }
        .scientific-detail-action:hover { background: rgba(224, 102, 102, 0.22); }

        /* DNA Loader */
        .dna-loader-container {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            padding: 0.2rem 0.5rem;
        }

        .dna-loader { display: flex; gap: 3px; }
        .dna-loader span {
            display: block;
            width: 3px;
            height: 15px;
            background: var(--coral-primary);
            animation: dna-bounce 1s infinite alternate;
            border-radius: 2px;
        }

        .dna-loader span:nth-child(2) { animation-delay: 0.15s; background: var(--coral-hover); }
        .dna-loader span:nth-child(3) { animation-delay: 0.3s; background: var(--cyan-accent); }
        .dna-loader span:nth-child(4) { animation-delay: 0.45s; background: var(--coral-hover); }
        .dna-loader span:nth-child(5) { animation-delay: 0.6s; background: var(--coral-primary); }

        .loader-text {
            font-size: 0.85rem;
            color: var(--text-secondary);
            font-style: italic;
        }

        /* Input Container */
        .input-container {
            flex-shrink: 0; 
            padding: 1.5rem 2rem 2rem 2rem;
            background: transparent;
        }

        .chat-input-wrapper {
            position: relative;
            background: rgba(10, 15, 30, 0.5);
            border: 1px solid var(--border-glass);
            border-radius: 16px;
            display: flex;
            align-items: flex-end;
            padding: 0.3rem 0.5rem;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
            transition: border-color 0.3s ease, box-shadow 0.3s ease;
        }

        .chat-input-wrapper:focus-within {
            border-color: rgba(224, 102, 102, 0.5);
            box-shadow: 0 0 15px rgba(224, 102, 102, 0.2), 0 8px 32px rgba(0, 0, 0, 0.2);
        }

        .chat-input {
            flex: 1;
            min-width: 0;
            background: transparent;
            border: none;
            outline: none;
            padding: 0.75rem 1rem;
            font-size: 0.95rem;
            font-family: inherit;
            line-height: 1.5;
            color: var(--text-primary);
            resize: none;
            max-height: 8.5rem;
            overflow-y: auto;
            overflow-wrap: anywhere;
        }

        .chat-input::placeholder { color: var(--text-secondary); opacity: 0.7; }

        /* Character-limit warning that pops out of the input box */
        .chat-input-warning {
            position: absolute;
            left: 0.75rem;
            bottom: calc(100% + 0.6rem);
            width: max-content;
            max-width: calc(100% - 1.5rem);
            padding: 0.55rem 0.85rem;
            background: linear-gradient(135deg, #e06666 0%, #d05555 100%);
            color: #fff;
            font-size: 0.78rem;
            line-height: 1.35;
            border-radius: 12px;
            box-shadow: 0 8px 24px rgba(224, 102, 102, 0.35);
            opacity: 0;
            transform: translateY(6px);
            transition: opacity 0.2s ease, transform 0.2s ease;
            pointer-events: none;
            z-index: 5;
        }

        .chat-input-warning::after {
            content: "";
            position: absolute;
            left: 1.5rem;
            top: 100%;
            border: 6px solid transparent;
            border-top-color: #d05555;
        }

        .chat-input-warning[hidden] { display: none; }

        .chat-input-warning.is-visible {
            opacity: 1;
            transform: translateY(0);
        }

        .send-btn {
            background: var(--coral-primary);
            border: none;
            outline: none;
            width: 44px;
            height: 44px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: #ffffff;
            transition: all 0.2s ease;
            box-shadow: 0 4px 10px rgba(224, 102, 102, 0.3);
        }

        .send-btn:hover { background: var(--coral-hover); transform: scale(1.05); }
        .send-btn:active { transform: scale(0.95); }
        .send-btn svg { width: 18px; height: 18px; fill: currentColor; transform: rotate(-45deg) translate(2px, -1px); }

        /* Animations */
        @keyframes pulse-border {
            0%, 100% { border-color: rgba(224, 102, 102, 0.3); box-shadow: 0 0 0 0 rgba(224, 102, 102, 0.1); }
            50% { border-color: rgba(224, 102, 102, 0.6); box-shadow: 0 0 15px 2px rgba(224, 102, 102, 0.2); }
        }
        @keyframes pulse-glow {
            0%, 100% { opacity: 0.6; box-shadow: 0 0 4px var(--cyan-accent); }
            50% { opacity: 1; box-shadow: 0 0 12px 2px var(--cyan-accent); }
        }
        @keyframes dna-bounce {
            0% { transform: scaleY(0.3); }
            100% { transform: scaleY(1.3); }
        }

        /* Responsive */
        @media (max-width: 900px) {
            .app-container { 
                grid-template-columns: minmax(0, 1fr); 
                height: 100vh;
                height: 100dvh; 
                width: 100%;
                border-radius: 0;
                border: none;
            }
            .sidebar { display: none; }
            .chat-header { padding: 0 1.5rem; }
            .messages-box { padding: 1.5rem; }
            .input-container { padding: 1rem 1.5rem 1.5rem 1.5rem; }
            .message-wrapper { max-width: 90%; }
        }
/* =========================================
   ESTILOS PARA EL BUSCADOR (SEARCH BAR)
   ========================================= */
.search-wrapper {
    margin-top: 0.8rem;
    margin-bottom: 0.8rem;
    padding: 0 16px; /* Aumentamos el padding lateral para hacerlo más angosto hacia el centro */
}

.search-input {
    width: 100%;
    background-color: rgba(10, 15, 30, 0.5);
    
    /* ICONO DE LUPA (Insertado de forma limpia mediante Data URI) */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%239ca3af'%3E%3Cpath d='M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    background-size: 16px;
    
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.6rem 1rem 0.6rem 2.3rem; /* Añadimos espacio a la izquierda para que el texto no pise la lupa */
    font-size: 0.85rem;
    color: #ffffff;
    outline: none;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.search-input:focus {
    border-color: rgba(77, 238, 234, 0.5);
    box-shadow: 0 0 10px rgba(77, 238, 234, 0.1);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Contenedor de la lista ajustado para el nuevo margen */
.traits-list {
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

/* =======================================================
   RESPONSIVE PARA WIDGET Y MÓVILES (Iframe de Django)
   ======================================================= */

/* 1er Nivel: Adaptación para el estándar de widget (hasta 450px) */
@media (max-width: 450px) {
    /* Cabecera más compacta */
    .chat-header {
        height: 60px;
        padding: 0 1rem;
    }

    .chat-status-text h2 { font-size: 1rem; }
    .chat-status-text p { font-size: 0.7rem; }
    
    /* Avatares y burbujas más pequeñas */
    .avatar { 
        width: 30px; 
        height: 30px; 
        font-size: 0.9rem; 
    }
    
    .messages-box {
        padding: 1rem;
        gap: 1rem;
    }

    .bubble {
        padding: 0.85rem 1rem;
        font-size: 0.85rem;
        line-height: 1.4;
    }

    /* Contenedor inferior con menos aire */
    .input-container { 
        padding: 0.8rem 1rem 1rem 1rem; 
    }
}

/* 2do Nivel: Ajustes extremos requeridos para anchos menores a 388px */
@media (max-width: 388px) {
    .chat-input-wrapper {
        position: relative; /* Posicionamiento relativo para anclar el botón flotante */
        padding: 0.2rem;
        border-radius: 20px;
    }

    .chat-input {
        /* Aumentamos el padding derecho a 3rem (48px) para que el texto que escriba el usuario nunca pise al botón flotante */
        padding: 0.7rem 3rem 0.7rem 1rem; 
        font-size: 0.85rem;
    }

    /* Transformamos el botón en un botón flotante interno (estilo WhatsApp / iMessage) */
    .send-btn {
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%); /* Centrado vertical perfecto */
        width: 32px;
        height: 32px;
        border-radius: 50%; /* Botón completamente redondo */
        margin: 0;
    }
    
    /* Ajuste de las animaciones del hover para no romper el centrado vertical */
    .send-btn:hover { 
        transform: translateY(-50%) scale(1.05); 
    }
    .send-btn:active { 
        transform: translateY(-50%) scale(0.95); 
    }
    
    .send-btn svg { 
        width: 14px; 
        height: 14px; 
        transform: rotate(-45deg) translate(1px, -1px); 
    }
}

.embedded-welcome { display: none; }

html.is-embedded body {
    min-height: 100vh;
    background: #0b1220;
}

html.is-embedded .app-container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    border: 0;
    border-radius: 0;
    background: #0b1220;
    box-shadow: none;
    min-height: 0;
}

html.is-embedded .sidebar { display: none; }

html.is-embedded .chat-header {
    height: auto;
    min-height: 0;
    padding: 8px 16px;
    justify-content: flex-end;
    background: transparent;
    border-bottom: 0;
}
html.is-embedded .chat-status { display: none; }

html.is-embedded .chat-area {
    width: 100%;
    min-height: 0;
    overflow: hidden;
    background: transparent;
}
html.is-embedded .messages-box { padding: 20px; }
html.is-embedded .messages-box.is-hidden { display: none; }

html.is-embedded .embedded-welcome {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 26px 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    text-align: center;
}

html.is-embedded .embedded-welcome.is-hidden { display: none; }
html.is-embedded .embedded-welcome__dna {
    display: grid;
    place-items: center;
    width: 92px;
    height: 92px;
    margin-bottom: 24px;
    border: 1px solid rgba(224, 102, 102, 0.3);
    border-radius: 50%;
    background: rgba(224, 102, 102, 0.1);
    font-size: 42px;
}
html.is-embedded .embedded-welcome h2 { font-size: 28px; font-weight: 600; }
html.is-embedded .embedded-welcome > p { max-width: 300px; margin: 10px 0 28px; color: var(--text-secondary); line-height: 1.5; }
html.is-embedded .embedded-welcome__actions { width: 100%; display: grid; gap: 10px; }
html.is-embedded .embedded-welcome__actions button,
html.is-embedded .embedded-trait-picker button {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 22px;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 60px;
    padding: 9px 14px 9px 10px;
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    background: #111a2a;
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}
html.is-embedded .embedded-welcome__actions button:hover,
html.is-embedded .embedded-trait-picker button:hover { border-color: rgba(224, 102, 102, 0.5); background: #162136; }
html.is-embedded .embedded-welcome__actions button:active { transform: translateY(1px); }
html.is-embedded .embedded-action__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; font-size: 17px; font-weight: 700; }
html.is-embedded .embedded-action__icon--coral { color: #f07a7a; background: rgba(224, 102, 102, 0.13); }
html.is-embedded .embedded-action__icon--cyan { color: #5fdad6; background: rgba(77, 238, 234, 0.1); }
html.is-embedded .embedded-action__icon--violet { color: #a98af5; background: rgba(139, 92, 246, 0.12); }
html.is-embedded .embedded-action__label { min-width: 0; color: var(--text-primary); font-size: 15px; font-weight: 500; line-height: 1.25; }
html.is-embedded .embedded-action__arrow { color: var(--text-secondary); font-size: 20px; text-align: right; }
html.is-embedded .embedded-trait-picker { width: 100%; margin-top: 14px; }
html.is-embedded .embedded-trait-picker.is-hidden { display: none; }
html.is-embedded .embedded-trait-picker input { width: 100%; padding: 12px; border: 1px solid var(--border-glass); border-radius: 10px; background: #111827; color: #fff; }
html.is-embedded #embedded-trait-options { max-height: 180px; margin-top: 8px; overflow-y: auto; }
html.is-embedded .embedded-trait-picker button { min-height: 42px; margin-bottom: 6px; font-size: 14px; }
html.is-embedded .input-container { padding: 14px 18px 12px; }

@media (max-height: 640px) {
    html.is-embedded .embedded-welcome {
        justify-content: flex-start;
        padding: 18px 20px 12px;
    }
    html.is-embedded .embedded-welcome__dna {
        width: 56px;
        height: 56px;
        margin-bottom: 12px;
        font-size: 28px;
    }
    html.is-embedded .embedded-welcome h2 { font-size: 22px; }
    html.is-embedded .embedded-welcome > p { margin: 8px 0 16px; }
    html.is-embedded .embedded-welcome__actions button { min-height: 48px; }
}

#open-traits-btn { display: none; }
html.is-embedded #open-traits-btn { display: flex; }

.chat-area { position: relative; }

.alba-traits-screen {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: #0b1220;
}
.alba-traits-screen.is-hidden { display: none; }
.alba-traits-screen__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.alba-traits-screen__header h2 { font-size: 18px; font-weight: 600; }
.alba-traits-screen__section-title {
    margin: 4px 0 8px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.alba-traits-screen__analysis-actions {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}
#alba-traits-search {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    background: #111827;
    color: #fff;
}
.alba-traits-screen__options {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    gap: 8px;
    align-content: start;
}
.alba-traits-screen__analysis-actions button,
.alba-traits-screen__options button {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    background: #111a2a;
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease;
}
.alba-traits-screen__analysis-actions button:hover,
.alba-traits-screen__options button:hover {
    border-color: rgba(224, 102, 102, 0.5);
    background: #162136;
}
.alba-traits-screen__empty { color: var(--text-secondary); font-size: 14px; padding: 8px 2px; }

/* Desktop trait-detail modal: a compact card centered over the chat area. */
.alba-trait-modal {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.alba-trait-modal.is-hidden { display: none; }
.alba-trait-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 7, 15, 0.6);
}
.alba-trait-modal__card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 380px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    padding: 18px;
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    background: #0f1626;
    box-shadow: 0 18px 48px rgba(4, 7, 15, 0.5);
}
.alba-trait-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.alba-trait-modal__header h3 { font-size: 17px; font-weight: 600; line-height: 1.3; }
.alba-trait-modal__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.55;
}
.alba-trait-modal__actions { margin-top: 16px; }
.alba-trait-modal__ask {
    width: 100%;
    padding: 11px 14px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, #1f2937 0%, #e06666 100%);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.alba-trait-modal__ask:hover { filter: brightness(1.05); }

.alba-feedback-modal {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.feedback-open-btn.is-hidden { display: none; }
.alba-feedback-modal.is-hidden { display: none; }
.alba-feedback-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 7, 15, 0.72);
}
.alba-feedback-modal__card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 20px;
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    background: #0f1626;
    box-shadow: 0 18px 48px rgba(4, 7, 15, 0.5);
}
.alba-feedback-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.alba-feedback-modal__header h3 {
    font-size: 18px;
    font-weight: 600;
}
.alba-feedback-stars {
    border: 0;
}
.alba-feedback-stars legend,
.alba-feedback-comment-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}
.alba-feedback-stars__options {
    display: inline-flex;
    gap: 3px;
    margin-bottom: 18px;
}
.alba-feedback-stars__options label {
    position: relative;
    cursor: pointer;
}
.alba-feedback-stars__options input {
    position: absolute;
    opacity: 0;
}
.alba-feedback-stars__options span[aria-hidden="true"] {
    display: block;
    padding: 2px;
    color: var(--text-secondary);
    font-size: 34px;
    line-height: 1;
    transition: color 120ms ease, transform 120ms ease;
}
.alba-feedback-stars__options label.is-active span[aria-hidden="true"] {
    color: var(--coral-hover);
}
.alba-feedback-stars__options label:hover span[aria-hidden="true"] {
    transform: translateY(-1px) scale(1.06);
}
.alba-feedback-stars__options input:focus-visible + span {
    border-radius: 4px;
    outline: 2px solid var(--coral-hover);
    outline-offset: 2px;
}
#feedback-comment {
    width: 100%;
    min-height: 112px;
    resize: vertical;
    padding: 11px 12px;
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font: inherit;
    line-height: 1.45;
}
#feedback-comment:focus {
    border-color: rgba(224, 102, 102, 0.7);
    outline: 2px solid rgba(224, 102, 102, 0.16);
}
.alba-feedback-message {
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.4;
}
.alba-feedback-message--error { color: #ff9b9b; }
.alba-feedback-submit {
    width: 100%;
    margin-top: 14px;
    padding: 11px 14px;
    border: 1px solid rgba(224, 102, 102, 0.5);
    border-radius: 8px;
    background: var(--coral-primary);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.alba-feedback-submit:disabled {
    cursor: wait;
    opacity: 0.6;
}
.alba-feedback-success {
    color: var(--text-primary);
    line-height: 1.5;
}
.alba-feedback-success.is-hidden,
.alba-feedback-message.is-hidden,
#alba-feedback-form.is-hidden {
    display: none;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 480px) {
    html.is-embedded .embedded-welcome { justify-content: flex-start; padding: max(70px, 9vh) 20px 18px; }
    html.is-embedded .embedded-welcome__dna { width: 78px; height: 78px; margin-bottom: 18px; font-size: 36px; }
    html.is-embedded .embedded-welcome h2 { font-size: 25px; }
    html.is-embedded .embedded-welcome > p { margin: 8px 0 22px; font-size: 15px; }
    html.is-embedded .input-container { padding: 12px 14px 16px; }
    .alba-feedback-modal { padding: 12px; }
    .alba-feedback-modal__card { padding: 16px; }
    .alba-feedback-stars__options { gap: 2px; }
}
